- /**
- * 截屏方法
- * @return
- */
- private Bitmap shot() {
- View view = getWindow().getDecorView();
- Display display = this.getWindowManager().getDefaultDisplay();
- view.layout(0, 0, display.getWidth(), display.getHeight());
- view.setDrawingCacheEnabled(true);//允许当前窗口保存缓存信息,这样getDrawingCache()方法才会返回一个Bitmap
- Bitmap bmp = Bitmap.createBitmap(view.getDrawingCache());
- return bmp;
- }
- //调用截屏方法,获得屏幕
- BitmapDrawable bd=new BitmapDrawable(shot());
- imageView.setBackgroundDrawable(bd);