Confused about home screen widget size in normal screen and larget screen

Posted by kknight on Stack Overflow See other posts from Stack Overflow or by kknight
Published on 2010-03-31T22:29:06Z Indexed on 2010/03/31 22:33 UTC
Read the original article Hit count: 683

Filed under:

I am designing a home screen widget. The widget layout file is like below.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="240dip" android:layout_height="200dip"
    android:background="@drawable/base_all"
/>

I ran this widget on a HTC Hero device, which has a screen of 320 pixels * 480 pixels with mdpi. It ran perfect on HTC Hero. The widget takes 3 cells * 2 cells space, i.e. 240 pixels * 200 pixels.

Then I ran this widget on a Nexus One device, which has a screen of 480 pixels * 800 pixels, mdpi. Since Nexus One also is mdpi, so I though 240dip is equivalent to 240 pixels on Nexus One and 200dip is equivalent to 200 pixels on Nexus One, so the widget will not take 3 cells * 2 cells space on Nexus One device. To my surprise, when running on Nexus One device, the widget take exact 3 cells * 2 cells, about 360 pixels * 300 pixels, on Nexus One device.

I am confused. The layout xml above specifies 240dip in width and 200dip in height for the widget, but why did it take 360 pixels * 300 pixels on Nexus One Device? What am I missing?

Thanks.

© Stack Overflow or respective owner

Related posts about android