Screenshot from Android

I have successfully captured the screen using the following code

View v1 = relativeView.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();

But this code is capturing the whole screen. I want to capture only components of a specific layout or region. Is this feasible in Android? Please give me some physical help

resolvent:

What I got from your question is that you have an ImageView on the relativelayout, and you want the snapshot of the ImageView not to be the whole relativelayout, not that you have nothing to do

Use only your code instead of relativelayout. In this case, let's say ImageView

ImageView v1 = (ImageView)findViewById(R.id.mImage);
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>