0

I want to get a screenshot in a scrollable view (ViewPager), but I´m only getting a image from what is in the screen.

I have a Viewpager with two childrens

android.support.v4.view.PagerTitleStrip

NoSaveStateFrameLayout

I´m using this code to get the screenshot

private Bitmap screenShot(View view) {

    Bitmap capture = null;
    
    view.setDrawingCacheEnabled(true);
    capture = Bitmap.createBitmap(view.getDrawingCache());
    view.setDrawingCacheEnabled(false);
    
    return capture;
}

I need to capture the hole content, the scrollable content that is not in screen yet.

Community
  • 1
  • 1
rendellhb
  • 149
  • 2
  • 9

2 Answers2

1

you can create bitmap of any view by following method

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

simply use above with your parent view and create bitmap of entire activity

Jack Gajanan
  • 1,596
  • 14
  • 18
0

I have found how to fix that here

You have to get the child height in Scrollable View.

Community
  • 1
  • 1
rendellhb
  • 149
  • 2
  • 9