Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

1x1 Android Widget shows as 2x2 widget on WXGA720 screen

I'm creating a 1x1 Android widget. I have designed images for each screen density as follows:

ldpi  (120 DPI) = 72 * (120 / 160) == 54 x 54 pixels
mdpi  (160 DPI) = 72 * (160 / 160) == 72 x 72 pixels
hdpi  (240 DPI) = 72 * (240 / 160) == 108 x 108 pixels
xhdpi (320 DPI) = 72 * (320 / 160) == 144 x 144 pixels

My widget specification:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" 
    android:minWidth="72dip"
    android:minHeight="72dip"
    android:updatePeriodMillis="1000"
    android:initialLayout="@layout/widget">
</appwidget-provider>

On WVGA800 screens (hdpi), the widget is 1x1. On WXGA800 screens (mdpi), the widget is 1x1. On WXGA720 screens (xhdpi), the widget is 2x2.

Can someone point me in the direction of what is wrong here?

like image 487
vulcanfk Avatar asked Feb 02 '23 08:02

vulcanfk


1 Answers

Before Android 4.0: (n * 74dip) - 2dip http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html

Android 4.0: 70 × n − 30 http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#anatomy

There's also padding that is automatically added when android:targetSdkVersion="14 or higher" is set.

like image 120
Jeremy Edwards Avatar answered Mar 23 '23 16:03

Jeremy Edwards