FC错误 :java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
调用截图方法时应用强制退出:
public Bitmap takeScreenShot(Activity activity){
//View是你需要截图的View
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
b1 = view.getDrawingCache();
//获取状态栏高度
Rect frame = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
//获取屏幕长和高
int width = activity.getWindowManager().getDefaultDisplay().getWidth();
//去掉标题栏
b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, b1.getHeight()-statusBarHeight);
view.destroyDrawingCache();
return b;
}