get Decoration View Bitmap - Android User Interface

Android examples for User Interface:View Bitmap

Description

get Decoration View Bitmap

Demo Code


//package com.java2s;
import android.app.Activity;
import android.graphics.Bitmap;
import android.view.View;

public class Main {
    public static Bitmap getDecorViewBitmap(Activity activity) {
        View decorView = activity.getWindow().getDecorView();
        return getViewBitmap(decorView);
    }/*  w  ww. ja  v  a2s. c  o  m*/

    public static Bitmap getViewBitmap(View view) {
        view.setDrawingCacheEnabled(true);
        Bitmap cache = view.getDrawingCache();
        if (cache == null) {
            return null;
        }
        Bitmap bitmap = Bitmap.createBitmap(cache);
        view.setDrawingCacheEnabled(false);
        return bitmap;
    }
}

Related Tutorials