我的 LinearLayout 中有这个 FrameLayout:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/desktopsFramelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="none"
android:src="@drawable/accept" />
</FrameLayout>
然后在代码中,我尝试像这样在 Drawable 中转换它:
FrameLayout desktopFrameLayout = (FrameLayout)findViewById(R.id.desktopsFramelayout);
desktopFrameLayout.setDrawingCacheEnabled(true);
desktopFrameLayout.buildDrawingCache();
Bitmap bitmap = desktopFrameLayout.getDrawingCache();
位图
是null
,为什么???
最佳答案
查看此链接并阅读 nininho 的回答: Android View.getDrawingCache returns null, only null
我认为它返回 null 因为你的 View 有维度 (0,0)
关于android 将 FrameLayout 转换为 Drawable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15223012/