SoFunction
Updated on 2025-04-06

Detailed explanation of screenshot examples of Android screen and view

Detailed explanation of screenshot examples of Android screen and view

Screenshot of visible area of ​​the screen

For the entire screenshot, you can use View view = getWindow().getDecorView();

public static Bitmap getNormalViewScreenshot(View view) {
    (true);
    ();
    return ();
  }

Overall screenshot of scrollview

public static Bitmap getWholeScrollViewToBitmap(View view) {
    ((0, ),
        (0, ));
    (0, 0, (), ());
    ();
    Bitmap bitmap = ();
    return bitmap;
  }

Overall screenshot of webview

public static Bitmap getWholeWebViewToBitmap(WebView webView) {
    Picture snapShot = ();
    Bitmap bmp = ((), (), .ARGB_8888);
    Canvas canvas = new Canvas(bmp);
    (canvas);
    return bmp;
  }

Overall screenshot of listview

public static Bitmap getWholeListViewItemsToBitmap(ListView listview) {

    ListAdapter adapter = ();
    int itemscount = ();
    int allitemsheight = 0;
    List<Bitmap> bmps = new ArrayList<Bitmap>();

    for (int i = 0; i < itemscount; i++) {

      View childView = (i, null, listview);
      (((), ),
          (0, ));

      (0, 0, (), ());
      (true);
      ();
      (());
      allitemsheight += ();
    }

    Bitmap bigbitmap = ((), allitemsheight, .ARGB_8888);
    Canvas bigcanvas = new Canvas(bigbitmap);

    Paint paint = new Paint();
    int iHeight = 0;

    for (int i = 0; i < (); i++) {
      Bitmap bmp = (i);
      (bmp, 0, iHeight, paint);
      iHeight += ();

      ();
      bmp = null;
    }
    return bigbitmap;
  }

If you need to take multiple screenshots, you need to use ();

Bitmap normalViewScreenshot = (mFrameContent);
        if (normalViewScreenshot != null) {
          Bitmap b = (normalViewScreenshot);
          (b);
          ();
        }

Thank you for reading, I hope it can help you. Thank you for your support for this site!