Java 拍摄Android CardView的布局截图
我试图捕捉我的一个布局,但在屏幕截图中得到黑色边框,如下图所示。我怎样才能删除它? 我截图的代码如下所示Java 拍摄Android CardView的布局截图,java,android,Java,Android,我试图捕捉我的一个布局,但在屏幕截图中得到黑色边框,如下图所示。我怎样才能删除它? 我截图的代码如下所示 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 a
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();
}
}
谢谢事实上,我没有收到你的密码
View v1= findViewById(R.id.quoteViewPager);
v1.getRootView();
应该是:
v1 = v1.getRootView();
希望它能帮助你:)事实上,我没有收到你的代码
View v1= findViewById(R.id.quoteViewPager);
v1.getRootView();
应该是:
v1 = v1.getRootView();
希望它能帮助您:)版面有空白吗?我在版面中使用它作为匹配父项…Thanksmargin不能是“匹配父项”。请阅读我的问题。哦,对不起…其中没有任何边距:(添加xml代码@rajubhai版面是否有边距?我已将其用作版面中的匹配父项…Thanksmargin不能是“匹配父项”。请阅读我的问题。哦,对不起…版面中没有任何边距:(添加您的xml代码@Rajubhai其全屏截图,我不需要全屏截图。然后我认为您选择了错误的布局,或者您选择的布局有边距。其全屏截图,我不需要全屏截图。然后我认为您选择了错误的布局,或者您选择的布局有边距。