Friday, January 25, 2013

Create bitmap image of selected layout in android


----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------

//This is your layout and image view 

ImageView imgView = (ImageView) findViewById(R.id.imageView1);
RelativeLayout rLayout1 = (RelativeLayout) findViewById(R.id.relativeLayout1);


. . .
. . .
. . .
. . .
. . .

//Code for create bitmap image from selected portion of layout.
//After that created bitmap image set in an image view

View v1 = rLayout1;    
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = v1.getDrawingCache();
//BitmapDrawable drawable = new BitmapDrawable(bitmap);
imgView.setImageBitmap(bitmap);


----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment