小部件配置活动可以消除小部件选择器中我的应用程序中的人群吗?

发布于 2025-01-04 00:26:16 字数 798 浏览 1 评论 0原文

我有一个小部件应用程序,可以有 12 种不同的小部件布局。目前,它会将系统小部件选择器挤满 12 个条目,因为我需要列出清单中的所有类,否则它们将不会执行。有没有办法处理小部件 xml 信息和布局定义,以便声明所有 12 个,但只有其中 3 个显示在小部件选择器中?

具体来说,我创建了集合支持的 stackview 和 listview 布局对象。这些布局中有 3 种不同类型的内容,为了方便起见,我为每种布局指定了 2 种尺寸(手机尺寸和平板电脑尺寸)。我扩展了基本提供程序和基本服务(视图工厂)类来创建特定的大小/布局/内容组合。我在清单中列出了所有提供者和服务类名称。我可以拥有这个并限制应用程序在小部件选择器中仅显示 3 种类型吗?

是否有我可以使用的小部件设计,配置活动可以在其中进行设置?换句话说,我是否可以使用配置活动来动态调整小部件的大小,而不管应用程序清单中小部件的信息 xml 文件中的设置是什么?配置活动可以在运行时设置布局对象(stackview/listview)并覆盖 android:initialLayout 标签吗?我的猜测是将初始布局设置为同时具有两者,然后在小部件提供程序的更新方法中将一个声明为可见,另一个声明为消失。初始远程视图是否在配置活动中创建?

感觉我可以使用正常/大和超大布局文件夹将系统小部件预览窗口中的列表修剪为 6 个。我希望只有 3 个,每种类型的内容一个。我将不胜感激专家的任何指导,即使是一个简单的答案,例如“这应该有效,但我还没有这样做。”

谢谢和问候,

PS - 值得注意的是 - 这是 Github 上的一个名为 WikiWidgets 的开源项目。这 3 种类型的内容是当天的照片、当天的专题文章以及来自维基百科的地理标记文章。

I have a widget app with 12 distinct widget layouts possible. At present, it will crowd the system widget picker with 12 entries because I need to list all of the classes in the manifest or they will not execute. Is there a way to handle the widget xml info and layout definitions so that all 12 are declared but only 3 of them display in the widget picker?

To be specific, I created collection backed stackview and listview layout objects. There are 3 different types of content to go into those layouts, and I specify 2 sizes for each layout for convenience (phone size and tablet size). I extend base provider and base service (view factory) classes to create the specific size/layout/content combinations. I have all of the provider and service class names enumerated in the manifest. Can I have this AND limit the app to displaying only the 3 types in the widget picker?

Is there a design for widgets I can use where the configuration activity can set things up? In other words, can I use the configuration activity to dynamically size the widget, regardless of what might be set in the widget's info xml file from the app manifest? Can the configuration activity set the layout object (stackview/listview) at runtime and override the android:initialLayout tag? My guess would be to set the initialLayout to have both and then declare one as visible and the other as gone in the widget provider's update method. Does the initial remote view get created in the Configuration Activity?

It feels like I can use the normal/large and x-large layout folders to trim my list to 6 in the system's widget preview window. I would prefer to have only 3, one for each type of content. I would be grateful for any guidance from the experts, even a simple answer like "that should work but I have not done it."

Thanks and regards,

PS - noteworthy - this is an open source project on Github called WikiWidgets. The 3 types of content are the photo of the day, the featured article of the day, and geo-tagged articles from Wikipedia.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错爱 2025-01-11 00:26:16

换句话说,我是否可以使用配置活动来动态调整小部件的大小,而不管应用程序清单中小部件的信息 xml 文件中的设置如何?

不。

配置活动可以在运行时设置布局对象(stackview/listview)并覆盖 android:initialLayout 标签吗?

无论谁使用 AppWidgetManager 更新应用程序小部件(配置活动、AppWidgetProvider 等),都可以指定其想要的布局。然而,这对大小没有影响——您仍然拥有元数据要求的任何大小,以可调整大小的小部件的任何用户更改为模。

初始远程视图是否在配置活动中创建?

应用程序中的任何内容都可以为应用程序小部件设置 RemoteViews(配置活动、AppWidgetProvider、下载数据和更新应用程序小部件的后台服务等)。然而,这对大小没有影响——您仍然拥有元数据要求的任何大小,以可调整大小的小部件的任何用户更改为模。

实际上,它们是可以调整大小的

在这种情况下,只需让用户调整它们的大小即可。

你的评论语气很糟糕

你搬起石头砸自己的脚,然后问我们为什么你的脚会痛。我的评论试图指出,如果你避免射击,你的脚就不会受伤。

对于配置活动没有太大帮助

很大程度上是因为配置活动与应用程序小部件大小无关。

我认为对于在平板电脑和手机上安装应用程序的用户来说,能够选择起始尺寸可能会有所帮助。

然后将内容是什么(“当天的照片、当天的特色文章和来自维基百科的地理标记文章”)的问题移至配置活动。通过在适当的资源集中包含应用程序小部件元数据的多个版本(例如,res/xml/widget.xml 和 res/xml-large/),您可以根据屏幕尺寸拥有多个起始尺寸。 widget.xml)。

In other words, can I use the configuration activity to dynamically size the widget, regardless of what might be set in the widget's info xml file from the app manifest?

No.

Can the configuration activity set the layout object (stackview/listview) at runtime and override the android:initialLayout tag?

Whoever uses AppWidgetManager to update the app widget (configuration activity, AppWidgetProvider, etc.) can specify whatever it wants for the layout. However, that has no impact on the size -- you still have whatever size your metadata asked for, modulo any user changes for resizeable widgets.

Does the initial remote view get created in the Configuration Activity?

Anything in your app can set up the RemoteViews for the app widget (configuration activity, AppWidgetProvider, a background service that downloads data and updates the app widget, etc.). However, that has no impact on the size -- you still have whatever size your metadata asked for, modulo any user changes for resizeable widgets.

Actually, they are resizeable

In which case, just let the user resize them.

Your comment has a lousy tone

You shot yourself in the foot, then asked us why your foot hurts. My comment was trying to point out that your foot would not hurt if you would avoid shooting it.

and does not help much with regards to the configuration activity

Largely because the configuration activity has nothing to do with the app widget size.

I thought it might be helpful for users installing the app on both a tablet and a phone to be able to choose the start size.

Then move the question of what the content is ("photo of the day, the featured article of the day, and geo-tagged articles from Wikipedia") to the configuration activity. You can have multiple starting sizes based on screen size by having multiple versions of your app widget metadata in appropriate resource sets (e.g., res/xml/widget.xml and res/xml-large/widget.xml).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文