Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试截取整个RelativeLayout视图组的屏幕截图并显示它,AlertDialog但图片是黑色的。
RelativeLayout
AlertDialog
这是实际的 RelativeLayout 的样子:
这就是我在对话框中得到的:
这是我的代码:
我在这里学到了。
从您发布的代码来看,您似乎只是在创建Bitmap而不是实际在其中绘制任何内容。您可以通过强制构建视图的绘图缓存并从缓存中拉取图像来生成视图组的位图。然后,您应该能够Bitmap将ImageView. 请参见下面的示例:
Bitmap
ImageView
viewGroup.buildDrawingCache(); Bitmap viewGroupBitmap = viewGroup.getDrawingCache(); image.setImageBitmap(viewGroupBitmap);
希望这可以帮助。