Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.view.View; import android.view.WindowManager; import android.widget.ScrollView; public class Main { public static Bitmap getBitmapFromView(View view) { Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(returnedBitmap); Drawable bgDrawable = view.getBackground(); if (bgDrawable != null) bgDrawable.draw(canvas); else canvas.drawColor(Color.WHITE); view.draw(canvas); return returnedBitmap; } public static Bitmap createBitmap(Context context, ScrollView v) { int width = 0, height = 0; for (int i = 0; i < v.getChildCount(); i++) { width += v.getChildAt(i).getWidth(); height += v.getChildAt(i).getHeight(); } if (width <= 0 || height <= 0) { return null; } int h = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight(); if (height < h) height = h; Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas); return bitmap; } }