This still need further investigation.
My HTC Desire comes with a number of widgets, and for example, the clock widget, if I choose it, it has a screen that let me choose what style of the clock I wanted. The most interesting thing here is, those clock comes with different sizes and style. From 2×1 to 4×2.
I tried sometime to implement this. Multiple style isn’t a problem. But problem is, I cannot leave the size that predefined in widget_provider.xml file (sort of such names, I miss camelCase).
Later I look at those official widgets from Google, and some of those famous widgets/apps in the market, when their stuff comes with different sizes, they are in separate item of the widget selection list. Oh, I suddenly realize that it might be HTC Sense’ special ability (ie, no one outside HTC could use).
To implement multiple widget sizes, Stack Overflow already got a good solution. But I think I could round-up in a simple check-list here:
- You need (for each widget(size) entry), one widgetprovider implementation. For example, small_widgetprovider, medium_widgetprovider.
- each widgetprovider register as one receiver in AndroidMainfest.xml
- That is.
<receiver android:name=".small_widgetprovider" android:label="small label"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider android:resource="@xml/small_widget_provider" /> </receiver> <receiver android:name=".medium_widgetprovider" android:label="medium label"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider android:resource="@xml/medium_widget_provider" /> </receiver>
In the original stackoverflow answer, it mention two widget share same provider, I tried but didn’t work. If anyone works, please share with us. Thanks