-2

I am developing a GPA Calculator application. For that purpose, I want to install some features related to capturing the screenshot of the final activity where the user will see the subjects and their marks and GPA etc. My root view is ScrollView Layout (all the contents i.e subjects their marks) and wants to capture it. I tried the following code but the code works fine only for the single view

 Bitmap bitmap = Bitmap.createBitmap(text1.getWidth() , text1.getHeight() , Bitmap.Config.ARGB_4444);
                bitmap.setDensity(text1.getResources().getDisplayMetrics().densityDpi);
                Canvas canvas = new Canvas(bitmap) ;
                text1.draw(canvas);
                imageView.setImageBitmap(bitmap);

But if I try the same code for the Parent View i.e Scroll View it gives Exception

Caused by: java.lang.IllegalArgumentException: width and height must be > 0

I want to Capture the whole Scroll View And save it to Internal Drive !! Thanks in Advance

1 Answers1

0

Use the drawingcache instead

Hope this helps

text1.setDrawingCacheEnabled(true);
Bitmap bitmap=text1.getDrawingCache();
Niza Siwale
  • 2,356
  • 1
  • 18
  • 20