Converting FrameLayout as Bitmap

android, android-framelayout

Solution

to overcome with this problem I destroy the drawingcache after saving the image.

savedImage.destroyDrawingCache();

Problem

I have a FrameLayout that consist some Image views & one EditText. I am saving this layout as an image in the memory (external). First time when I set the images in imageviews everything goes fine i.e. the exact image is being saved (same as displaying on screen) but when after saving first time if I change any thing (text, image) it displays correctly on screen but in saved image it displays earlier image (first image). XML of Layout: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@+id/imageWithoutFrame" android:layout_height="match_parent" android:layout_width="match_parent" android:layout_centerInParent="true" > <ImageView android:id="@+id/withoutFrame_background" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/background" /> <ImageView android:id="@+id/withoutFrame_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:adjustViewBounds="true" android:layout_gravity="center" /> <EditText android:id="@+id/withoutFrame_editableText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" android:layout_marginBottom="30dip" android:hint="Write here" android:maxLength="60" /> </FrameLayout> </RelativeLayout> ``` Code that change it in bitmap is: ``` Bitmap bm = null; FrameLayout savedImage = null; savedImage = (FrameLayout)findViewById(R.id.imageWithoutFrame); savedImage.setDrawingCacheEnabled(true); savedImage.buildDrawingCache(); bm = savedImage.getDrawingCache(); ``` I used this bm for saving. Thanks for helping.

Original source