1.在手机的图片查看器是没有颜色背景的(没有黑色就显示为黑色)。而画笔的颜色是默认黑色的,所以需要一个非黑色的背景才能够看到黑色的字体。
下面是截屏的关键代码:是从顶层View绘制,所以contentView为根的子控件树不加背景也是可以看到黑色字体的,因为顶层View应该是绘制了白色背景的
static Bitmap getListViewScreenShot(Activity a){
View view = a.getWindow().getDecorView();
/*view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap b1 = view.getDrawingCache();*/
Canvas canvas = new Canvas();
Bitmap b1 = Bitmap.createBitmap(720, 1200, Bitmap.Config.ARGB_8888);
canvas.setBitmap(b1);
view.draw(canvas);
Rect frame = new Rect();
a.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
System.out.println(statusBarHeight);
int width = a.getWindowManager().getDefaultDisplay().getWidth();
int height = a.getWindowManager().getDefaul