【问题标题】:Custom Layout in Homescreen Widget主屏幕小部件中的自定义布局
【发布时间】:2023-03-17 02:33:01
【问题描述】:

我正在开发一个具有许多不同大小按钮的主屏幕小部件。为了最大限度地利用空间,我想为这个小部件使用流式布局(出于某种疯狂的原因,android 没有本机实现)。

为了解决这个问题,我尝试使用第三方实现并自己实现了布局,但是,加载小部件时总是出现异常:

W/AppWidgetHostView: updateAppWidget couldn't find any view, using error view
                                                android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class [redacted].FlowLayout
                                                Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class [redacted].FlowLayout
                                                Caused by: java.lang.ClassNotFoundException: Didn't find class "[redacted].FlowLayout" on path: DexPathList[[zip file "/system/priv-app/Velvet/Velvet.apk"],nativeLibraryDirectories=[/system/priv-app/Velvet/lib/arm64, /system/priv-app/Velvet/Velvet.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/lib64, /vendor/lib64]]

我的小部件布局如下所示:

<[redacted].FlowLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#09C"
android:padding="@dimen/widget_margin"
android:id="@+id/widgetRoot"
android:orientation="horizontal">


</[redacted].FlowLayout>

假设编辑的命名空间是正确的,有什么方法可以做我想做的,还是不可能使用带有主屏幕小部件的自定义布局?

【问题讨论】:

    标签: java android widget


    【解决方案1】:

    主屏幕小部件是非常有限的东西,它们不支持自定义布局:https://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

    【讨论】:

    • 太好了,感谢您的确认,您知道有什么方法可以做我想做的事吗?网格布局并没有真正削减它,因为我发现它在同一列中的小按钮与宽按钮浪费了大量空间
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多