简体   繁体   中英

Screen capture in android

I have successfully captured the screen with following code.

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

But with this code whole screen is capturing. I want to capture only the components of a particular layout or area. Is this possible in android? Please some body help.

What I got from your question suppose you have ImageView on your RelativeLayout and you want the snap of that Imageview not the whole RelativeLayout than you have nothing to do.

Just use your code only instead of using relativelayout use that View lets say ImageView in this case

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM