1

I need capture a scrollview that exceed the visible UI, I used this code:

ScrollView view2 = (ScrollView)findViewById(R.id.scrollCapture);
    view2.setDrawingCacheEnabled(true);
    view2.buildDrawingCache();
    Bitmap bm = view2.getDrawingCache();

but it only capture showed screen, not the entire layout.

Is there some method to capture whole layout even isnt showed?

Thanks a lot.

2 Answers2

0

Instead of using scrollview use the direct child (only one direct child is allowed). For example if your xml file is

<ScrollView
 android:id="@+id/scrollCapture">
  <LinearLayout
    android:id="@+id/scrollCaptureChild">
  </LinearyLayout>
</ScrollView>

do

LinearyLayout view3 = (LinearyLayout)findViewById(R.id.scrollCaptureChild);
view3.setDrawingCacheEnabled(true);
view3.buildDrawingCache();
Bitmap bm = view3.getDrawingCache();
Anirudha Agashe
  • 3,510
  • 2
  • 32
  • 47
  • Thanks for your attention, but my activity looks like that, anyways seems like there is no way to capture the part of the screen that isnt shown by the UI :(, i tried a lot of things but no way to do that :( – user2854628 Nov 15 '13 at 16:08
  • only the visible part on the screen is captured – Sagar Patil Oct 23 '15 at 09:37
  • try the solution marked as accepted answer at http://stackoverflow.com/questions/9791714/take-a-screenshot-of-a-whole-view – Anirudha Agashe Oct 23 '15 at 09:57
0
Bitmap bitmap = Bitmap.createBitmap(scrollView.getChildAt(0).getWidth(), scrollView.getChildAt(0).getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
scrollView.getChildAt(0).draw(c);
Aleh
  • 386
  • 4
  • 8