我有这个布局,并尝试在一个Bitmap中保存FrameLayout和所有子项。 getDrawingCache不返回Bitmap。我尝试this和this但无效。
<FrameLayout
android:id="@+id/flPhoto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageOne"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:src="@drawable/image1"/>
<ImageView
android:id="@+id/imageTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/image2"
android:layout_gravity="bottom|right"
android:layout_margin="15dp"/>
</FrameLayout>
imageOne.buildDrawingCache();
imageTwo.buildDrawingCache();
flPhoto.setDrawingCacheEnabled(true);
flPhoto.buildDrawingCache();
mergedPhoto = flPhoto.getDrawingCache();
String pathSavedBitmapFile = MediaStore.Images.Media.insertImage(getContentResolver(), mergedPhoto, "", null);
flPhoto.destroyDrawingCache();