简体   繁体   English

主屏幕小部件中的自定义布局

[英]Custom Layout in Homescreen Widget

I am developing a homescreen widget that has a number of different sized buttons. 我正在开发一个具有许多不同大小按钮的主屏幕小部件。 To maximize the use of space, I want to use a flow layout for this widget (which for some crazy reason, android has no native implementation of). 为了最大限度地利用空间,我想为此小部件使用流布局(出于某种疯狂的原因,android没有其本机实现)。

To solve this, I have tried using third party implementations and implemented the layout myself, however, I always get an exception when loading the widget: 为了解决这个问题,我尝试使用第三方实现并自己实现了布局,但是,加载小部件时总是会遇到异常:

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]]

My layout for the widget looks only like this: 我的小部件布局仅如下所示:

<[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>

Assuming that the redacted namespace is correct, is there any way to do what I want or is it impossible to use a custom layout with a homescreen widget? 假定编辑的名称空间正确,是否有任何方法可以做我想要的事情,或者不可能将自定义布局与主屏幕小部件一起使用?

主屏幕小部件不受限制,它们不支持自定义布局: https : //developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM