0

I would like to ask help. I want to take screenshot. This is working, but ImageView rounded corners are not rounded on the taken screenshots (and elevation shadows missing too). I used

imageView.setClipToOutline(true);

to make this work on the phone, but on the screenshots they are rectangular.

These are my screenshot utils:

public class ScreenShotUtils {

public static Bitmap screenShotFromCanvas(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
            view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);
    return bitmap;
}

public static Bitmap screenShotFromDrawingCache(View view) {
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();

    Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());

    view.destroyDrawingCache();
    view.setDrawingCacheEnabled(false);

    return bitmap;
}

Both method has the same result.

However i noticed, that if i turn the hardware acceleration off, the layout looks like the same as on the screenshots.

This is how it looks like after take screenshot: enter image description here

This is how it should be: enter image description here

László Magyar
  • 355
  • 1
  • 16
  • You can try this options - https://stackoverflow.com/questions/2459916/how-to-make-an-imageview-with-rounded-corners – Vadim Eksler Nov 05 '18 at 13:32
  • This is not what i want. It's just create a bitmap with a predefined corner radius and color. This is really static way, and not what i want. I want my entire view-hierarchy to draw into a bitmap correctly, dynamically, so basically i want to take a proper screenshot of the screen! – László Magyar Nov 05 '18 at 14:14

1 Answers1

0

Finally i solved my problem with MediaProjectionManager.

László Magyar
  • 355
  • 1
  • 16