我写了一些代码,可以将TableLayout转换为位图。一切工作正常,但是我的位图有黑色背景。 这是我的源代码:
public Bitmap sendMyData(TableLayout view) {
Bitmap bitmap = null;
ByteArrayOutputStream bbb = new ByteArrayOutputStream();
view.setDrawingCacheEnabled(true);
view.layout(0, 0, view.getWidth(), view.getHeight());
view.buildDrawingCache(true);
bitmap = Bitmap.createBitmap(view.getDrawingCache());
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bbb);
view.setDrawingCacheEnabled(false);
return bitmap;
}
我的代码有什么问题?为什么我的位图有黑色背景?如果有人知道解决方法,请帮忙一下,谢谢。