いくつかの Image ビューと 1 つの EditText で構成される FrameLayout があります。このレイアウトを画像としてメモリ(外部)に保存しています。初めてimageviewsで画像を設定すると、すべてうまくいきます。つまり、正確な画像が保存されます(画面に表示されるのと同じ)が、最初に保存した後、何か(テキスト、画像)を変更すると、画面に正しく表示されますが、保存されます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>
ビットマップでそれを変更するコードは次のとおりです。
Bitmap bm = null;
FrameLayout savedImage = null;
savedImage = (FrameLayout)findViewById(R.id.imageWithoutFrame);
savedImage.setDrawingCacheEnabled(true);
savedImage.buildDrawingCache();
bm = savedImage.getDrawingCache();
このbmを保存に使用しました。
助けてくれてありがとう。