I created an XML file for an AppWidget as shown below.
xml/appwidget_4x1.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="@dimen/AppWidget_4Cell"
android:minHeight="@dimen/AppWidget_1Cell"
android:updatePeriodMillis="0"
android:previewImage="@drawable/appwidget_4x1_preview"
android:initialLayout="@layout/appwidget_4x1_loading"
android:resizeMode="horizontal"
android:minResizeWidth="@dimen/AppWidget_3Cell" />
The problem is in Android 1.6 it apparently doesn't like me using the @dimen statements for the minWidth and minHeight. When this happens and the user drops an AppWidget on the screen it says, "No more room on this home screen." If I use the dimensions explicitly it starts working again.
res/values/dimens.xml (1.6 - 3.2)
<dimen name="AppWidget_1Cell">72dp</dimen>
<dimen name="AppWidget_4Cell">294dp</dimen>
res/values-v14/dimens.xml (4.0+)
<dimen name="AppWidget_1Cell">40dp</dimen>
<dimen name="AppWidget_4Cell">250dp</dimen>
Is this a bug and if so what's the work around for this? I did it this way to follow the recommendations for Ice Cream Sandwich's new widget layout dimensions.
I just tried that and it happens also to me with Android 1.6. A quick fix is to create different xml folders (one for Android 1.6, and one for the other versions). So, you could have:
xml-v4 (for Android 1.6), containing dimensions as numeric values
xml-v5 (for the rest), containing dimensions as @dimen/..
or, you could have:
xml (for Android 1.6 - 3.2), containing dimensions as numeric values
xml-v14 (for Android 4), containing the new dimensions
What's bad is that you have to duplicate your appwidget providers xml files, but at least it works.
Mmm..I'm thinking about dropping support for Android 1.6.....(right now it's at 1.3%...).
Cheers, Yuvi