Here you can find the source of prepare(Activity activity, int id, int width)
public static void prepare(Activity activity, int id, int width)
//package com.java2s; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Rect; import android.view.ViewGroup; import android.view.Window; public class Main { private static Bitmap sCoverBitmap = null; private static int sWidth = -1; public static void prepare(Activity activity, int id, int width) { if (sCoverBitmap != null) { sCoverBitmap.recycle();/*from www . ja va 2 s .c o m*/ } Rect rectgle = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectgle); int statusBarHeight = rectgle.top; ViewGroup v1 = (ViewGroup) activity.findViewById(id).getRootView(); v1.setDrawingCacheEnabled(true); Bitmap source = Bitmap.createBitmap(v1.getDrawingCache()); v1.setDrawingCacheEnabled(false); if (statusBarHeight != 0) { sCoverBitmap = Bitmap .createBitmap(source, 0, statusBarHeight, source.getWidth(), source.getHeight() - statusBarHeight); source.recycle(); } else { sCoverBitmap = source; } sWidth = width; } }