public static BitmapDescriptor fromView(View view) {

        // TODO: Single views have trouble with measure.
        final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        view.measure(spec, spec);

        final int width = view.getMeasuredWidth();
        final int height = view.getMeasuredHeight();

        view.layout(0, 0, width, height);

        final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Canvas canvas = new Canvas(bitmap);

        view.draw(canvas);

        return BitmapDescriptorFactory.fromBitmap(bitmap);
    }
public static BitmapDescriptor fromView(View view) {

        
        final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        view.measure(spec, spec);

        final int width = view.getMeasuredWidth();
        final int height = view.getMeasuredHeight();

        view.layout(0, 0, width, height);

        final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Canvas canvas = new Canvas(bitmap);

        view.draw(canvas);

        return BitmapDescriptorFactory.fromBitmap(bitmap);
    }
public static BitmapDescriptor fromView ( View view ) { // TODO: Single views have trouble with measure. final int spec = View . MeasureSpec . makeMeasureSpec ( 0 , View . MeasureSpec . UNSPECIFIED ) ; view . measure ( spec , spec ) ; final int width = view . getMeasuredWidth ( ) ; final int height = view . getMeasuredHeight ( ) ; view . layout ( 0 , 0 , width , height ) ; final Bitmap bitmap = Bitmap . createBitmap ( width , height , Bitmap . Config . ARGB_8888 ) ; final Canvas canvas = new Canvas ( bitmap ) ; view . draw ( canvas ) ; return BitmapDescriptorFactory . fromBitmap ( bitmap ) ; }
Returns a bitmap icon showing a screenshot of the view passed in.

@param view View to convert
@return Bitmap icon of view
Returns a bitmap icon showing a screenshot of the view passed in .