Search code examples
androidscreenshot

Take a screenshot of a whole View


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?


Solution

  • 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;
    }