转换的FrameLayout为位图 [英] Converting FrameLayout as Bitmap
问题描述
我有一个由一些图像视图和放A的FrameLayout; 1的EditText。我保存此布局中的存储器(外部)的图像。当我在imageviews一切设定的图像第一时间的推移罚款即确切的图像被保存(同在屏幕上显示),但是当保存后第一时间,如果我改变任何东西(文字,图片),它正确地显示在屏幕上,但在保存图像将显示早期的图像(第1图像)。
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:
<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,它改变它的位图:
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();
我用这个BM保存。
I used this bm for saving.
感谢您的帮助。
推荐答案
要克服这个问题,我破坏了drawingcache保存图像之后。
to overcome with this problem I destroy the drawingcache after saving the image.
savedImage.destroyDrawingCache();
这篇关于转换的FrameLayout为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!