Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take a screenshot of a whole View [duplicate]

I have built a table which is basically done by HorizontalScrollView inside a ScrollView. I made the user can edit the fields.

Now I want to save the table on a screen, jpg, png, pdf or anything else.

The problem is - the table is nearly always bigger than the screen.

Is there a way to make a screenshot of the whole ScrollView layout? If not what do you think can do the job?

like image 512
softwaresupply Avatar asked Mar 20 '12 17:03

softwaresupply


People also ask

How do I take a screenshot of a full-page scroll?

Open the webpage you want to capture, then press and hold “Ctrl” + “Alt.” Then, press the “Prtsc” key. Left-click on the corner of the red highlighted box and drag to select the screenshot area. Once you release the mouse, the page will start slowly scrolling on its own.


2 Answers

Actually I found the answer:

public static Bitmap loadBitmapFromView(View v) {     Bitmap b = Bitmap.createBitmap(v.getWidth() , v.getHeight(), Bitmap.Config.ARGB_8888);                     Canvas c = new Canvas(b);     v.draw(c);     return b; } 
like image 107
softwaresupply Avatar answered Oct 01 '22 05:10

softwaresupply


  ScrollView iv = (ScrollView) findViewById(R.id.scrollView);   Bitmap bitmap = Bitmap.createBitmap(         iv.getChildAt(0).getWidth(),          iv.getChildAt(0).getHeight(),          Bitmap.Config.ARGB_8888);   Canvas c = new Canvas(bitmap);   iv.getChildAt(0).draw(c);    // Do whatever you want with your bitmap   saveBitmap(bitmap); 
like image 29
hackjutsu Avatar answered Oct 01 '22 05:10

hackjutsu