Zehra Batool
Zehra Batool

Reputation: 11

screenshot of specific layout that is nested in main layout

I want to take a screen shot of a layout that is nested (in between) main layout. I'm using following code:

public static Bitmap captureScreen(View v) {

        Bitmap bitmap = null;


        try {
            if (v != null) {
                int width = v.getWidth();
                int height = v.getHeight();

                screenshot = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
                v.draw(new Canvas(screenshot));

            }
        } catch (Exception e) {

            Log.d("captureScreen", "Failed");
        }

        return bitmap;
    }

on button click it would be like :

captureScreen(midlayout);

Upvotes: 1

Views: 69

Answers (0)

Related Questions