Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take A Partial Screenshot on Android?

I want to save off a Bitmap of the current screen for my users to share, but I only want to do a partial (I want to remove the areas that have user buttons and such).

I have found code on taking a full screenshot, but cannot figure out how to do this.

Hoping there is something easy that I am just missing.

Thanks in advance.

like image 323
RiddlerDev Avatar asked Jan 28 '13 04:01

RiddlerDev


People also ask

How do I take a screenshot of only part of the screen?

Press Ctrl + PrtScn keys. The entire screen changes to gray including the open menu. Select Mode, or in earlier versions of Windows, select the arrow next to the New button. Select the kind of snip you want, and then select the area of the screen capture that you want to capture.

Is there a snipping tool for Android?

Snip for Android can be downloaded from the Google Play Store. The Android app can be used on mobile and tablet devices.


1 Answers

Put the partial area of which the screenshot is to be taken in a ViewGRoup say RelativeLayout. Then when you launch the Activity just make sure to build the drawing cache as follows

relativeLayout = (RelativeLayout)findViewById(R.id.relativeLayout);
        relativeLayout.setDrawingCacheEnabled(true);
        relativeLayout.buildDrawingCache();

And then when you actually want ot take the screenshot of that particular area, just get the Screenshot in the form of a Bitmap from the drawing cache

bitmap = relativeLayout.getDrawingCache();
like image 73
Antrromet Avatar answered Sep 22 '22 19:09

Antrromet