[英]Save the Image of activity on click of menu item
我有一个活动,单击菜单项后要保存,我想将屏幕图像保存到我的设备中的特定文件夹中。 我该怎么做。 ?
在后台显示的图像是ImageView,文本是textview。 我必须合并它们并将它们保存为单个图像。
尝试在菜单项单击事件上使用以下代码。
View v = view.getRootView();
v.setDrawingCacheEnabled(true);
Bitmap b = v.getDrawingCache();
// give path of external directory to save image
String extr = Environment.getExternalStorageDirectory().toString();
File myPath = new File(extr, "test.jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(myPath);
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
其中视图v是根布局...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.