[英]Taking Screenshot of Layout Android CardView
I am trying to capture one of my layout but getting black border in screenshot like below. 我试图抓住我的一个布局,但在下面的屏幕截图中获得黑色边框。 How can I remove it ?
我该如何删除它?
My code for taking screenshot is like below 我的截屏代码如下所示
private void takeScreenshot() {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
// create bitmap screen capture
View v1= findViewById(R.id.quoteViewPager);
v1.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
}
Thanks 谢谢
Actually, I didn't get your code, 实际上,我没有得到你的代码,
View v1= findViewById(R.id.quoteViewPager);
v1.getRootView();
it should be : 它应该是 :
v1 = v1.getRootView();
Hope it will help you :) 希望它能帮到你:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.