gpt4 book ai didi

android 将 FrameLayout 转换为 Drawable

转载 作者:行者123 更新时间:2023-11-30 03:44:27 28 4
gpt4 key购买 nike

我的 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com