2012-05-10 6 views
4

일부 이미지 뷰 & 하나의 EditText로 구성된 FrameLayout이 있습니다. 이 레이아웃을 메모리 (외부)의 이미지로 저장합니다. 처음으로 imageviews에서 이미지를 설정할 때 모든 것이 잘됩니다. 즉, 정확한 이미지가 저장됩니다 (화면에 표시되는 것과 동일 함). 그러나 처음 저장하면 (텍스트, 이미지) 어떤 것이나 화면에 올바르게 표시되지만 저장 될 때 이미지는 이전 이미지 (첫 번째 이미지)를 표시합니다. 레이아웃의FrameLayout을 비트 맵으로 변환

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을 사용했다.

도와 주셔서 감사합니다.

답변

3

이 문제를 극복하기 위해 이미지를 저장 한 후 드로어 캐시를 파괴합니다.

savedImage.destroyDrawingCache(); 
+0

감사합니다. 내 문제도 해결합니다. –

+0

솔루션과 view의 차이점은 무엇입니까? setDrawingCacheEnabled (false); –

관련 문제