[英]How to get Home Screen Widget Size
In android 4.2, there is a new callback called onWidgetOptionChanged() in which a bundle containing the widget size information is passed back. 在android 4.2中,有一个名为onWidgetOptionChanged()的新回调,其中包含小部件尺寸信息的包将被传回。 http://developer.android.com/guide/topics/appwidgets/index.html#AppWidgetProvider
http://developer.android.com/guide/topics/appwidgets/index.html#AppWidgetProvider
My question is, how do we get the widget size prior to android 4.2? 我的问题是,如何在android 4.2之前获取小部件大小?
I need to set a picture to an ImageView in the widget but I need to know the size of the ImageView / Widget to scale the picture accordingly. 我需要在小部件中为ImageView设置图片,但是我需要知道ImageView /小部件的大小才能相应地缩放图片。
Also, the layout used for the widget changes depending on its size. 同样,用于窗口小部件的布局根据其大小而变化。 Without onWidgetOptionChanged(), how does one know when to use a different layout depending on the size of the widget?
没有onWidgetOptionChanged(),如何知道何时根据窗口小部件的大小使用不同的布局?
I'm afraid that you cannot get current widget size on android before 4.2. 恐怕您无法在4.2之前的android上获得当前的小部件大小。 Only preconfigured widget size through
android.appwidget.AppWidgetManager#getAppWidgetInfo
. 仅通过
android.appwidget.AppWidgetManager#getAppWidgetInfo
预先配置的小部件尺寸。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.