public void printScreen(View view) {
String imgPath = "/storage/emulated/0/Pictures/test.png";
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
if (bitmap != null) {
try {
FileOutputStream out = new FileOutputStream(imgPath);
bitmap.compress(Bitmap.CompressFormat.PNG, 100,
out);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Android开发截屏某控件
最新推荐文章于 2023-09-28 00:15:00 发布