在我的应用程序中,我只能捕获可见区域,但滚动区域不会显示在捕获的图像中。为此,我做到了,
private void saveBitmap(Bitmap bitmap) {
shopPath = new File(Environment.getExternalStorageDirectory() + "/Shopping_List.png");
FileOutputStream fos;
try {
fos = new FileOutputStream(shopPath);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
Log.e("FileException", e.getMessage(), e);
} catch (IOException e) {
Log.e("InputException", e.getMessage(), e);
}
}
private Bitmap takeScreenshot() {
View rootView = findViewById(android.R.id.content).getRootView();
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
它只是采取了可见的镜头,但没有完全活动..这超出了屏幕..请帮助我..提前谢谢你。
答案 0 :(得分:-1)
view.measure(MeasureSpec.makeMeasureSpec(
MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(),
view.getMeasuredHeight());
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bm = Bitmap.createBitmap(view.getMeasuredWidth(),
webView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas bigcanvas = new Canvas(bm);
view.draw(bigcanvas);
我只是试过这个有用......它的代码不一样,但是你明白了... oyu现在可以使用位图!!