简体   繁体   English

如何在运行时更改android app小部件的大小?

[英]How to change android app widget size at runtime?

I know that one cannot change the size of an app widget. 我知道不能更改应用程序小部件的大小。 But what to do if I need to? 但是,如果需要我该怎么办? I know that there can be several receivers in AndroidManifest.xml, each with its own provider_info.xml, but users can switch between them only while adding widget on the homescreen. 我知道AndroidManifest.xml中可以有多个接收器,每个接收器都有自己的provider_info.xml,但是用户只有在主屏幕上添加小部件时才能在它们之间切换。 Is there any way to switch between different app widget providers at runtime? 有什么方法可以在运行时在不同的应用程序小部件提供程序之间切换吗?

Is there any way to switch between different app widget providers at runtime? 有什么方法可以在运行时在不同的应用程序小部件提供程序之间切换吗?

No, not as far as I'm aware. 不,据我所知。 I believe this is the reason why some applications include widgets in various different sizes. 我相信这就是某些应用程序包含各种不同大小的小部件的原因。

It's also not possible for the user to change the size of widgets, if you need to support Android 2.0+. 如果您需要支持Android 2.0+,则用户也无法更改小部件的大小。

Edit: As of Android 4.1, it is actually possible to have different layouts for resizable widgets. 编辑:从Android 4.1开始,实际上可以为可调整大小的小部件使用不同的布局。 The layouts change according to the size of the widget. 布局根据窗口小部件的大小而变化。

I've read that beginning from the Honeycomb 3.1 you can resize your App Widgets. 我已经读过,从Honeycomb 3.1开始,您可以调整App Widget的大小。 You should specify minResizeWidth and minResizeHeight in your appwidget_info.xml file and use layouts for widget that can be resized. 您应该在appwidget_info.xml文件中指定minResizeWidth和minResizeHeight,并对可调整大小的窗口小部件使用布局。 More about this you can find here . 有关此的更多信息,请参见此处

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

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