I've written a widget which is supposed to be 4x2 homescreen blocks. It's minheight and minwidth, with accordance to the current "App Widget Design Guidelines" page are
android:minWidth="250dp"
android:minHeight="110dp"
And a padding is applied from dimens.xml if the system version is below Ice Cream Sandwich
On my Nexus 4 (xhdpi, Jellybean 4.2.1), this widget is 4x2. On an emulator (hdpi, Gingerbread 2.3.3), this widget is 4x2. On my Nexus 7 however (hdpi, Jellybean 4.2.1), the widget is 3x2. I can't for the life of me figure out why or how to fix it. Any thoughts?
Lars Vogel writes in this Home Screen Widget tutorial that:
As a calculation rule you should define the size of the widget with the formula: ((Number of columns / rows)* 74) - 2. These are device independent pixels and the -2 is used to avoid rounding issues.
Edit: apparently Vogel got it from the old Widget API documentation (scroll down past mid page to see reference).
Based on this measurement, for a 4 cells width and 2 cells height, use 294 x 146 dip:
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dip" android:minHeight="146dip"
android:updatePeriodMillis="0" android:initialLayout="@layout/some_layout" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With