本文介绍了如何采取截图编程,并将其保存在画廊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我会知道什么是code取当前屏幕的截图(后一个按钮,preSS)并将其保存在一个画廊,因为我没有使用SD卡的设备。所以我会保存在默认画廊。谢谢
解决方案
点阵位图;
查看V1 = findViewById(R.id.rlid); //获取乌尔根视图id
v1.setDrawingCacheEnabled(真正的);
位图= Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(假);
这应该做的伎俩。
有关节能
ByteArrayOutputStream字节=新ByteArrayOutputStream();
bitmap.com preSS(Bitmap.Com pressFormat.JPEG,40个字节);
文件F =新的文件(Environment.getExternalStorageDirectory()
+文件分割符+test.jpg放在)
f.createNewFile();
FileOutputStream中FO =新的FileOutputStream(F);
fo.write(bytes.toByteArray());
fo.close();
i would to know what is the code to take a screenshot of the current screen (after a press of a button) and save it on a gallery because I don't have a device with sd cards. So i would to save in the default gallery. thank you
解决方案
Bitmap bitmap;
View v1 = findViewById(R.id.rlid);// get ur root view id
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
This should do the trick.
For saving
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "test.jpg")
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.close();
这篇关于如何采取截图编程,并将其保存在画廊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!