tags:

views:

398

answers:

2

From Android widget screen guidelines, http://developer.android.com/guide/practices/ui_guidelines/widget_design.html, we know that, home screen has 4*4 cells, and in portrait orientation, each cell is 80 pixels wide by 100 pixels tall.

I think these are for baseline HVGA screen. How about for large screens and hdpi screens, do they still have 4*4 cells for widget and each cell in portrait orientation is still 80 pixels * 100 pixels?

Thanks.

+1  A: 

The pixels you are referring to are device independent pixels. As you can see in the documentation here:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="294dp"
    android:minHeight="72dp"
    android:updatePeriodMillis="86400000"
    android:initialLayout="@layout/example_appwidget"
    android:configure="com.example.android.ExampleAppWidgetConfigure" >
</appwidget-provider>

Note how they are using dp units, not px. This allows the widget to scale correctly to different screen resolutions.

As for the screen being 4x4 cells, this is a property of the default Android homescreen manager. Regardless of screen resolution the home screen will be 4x4 cells when using the default Android home screen.

There are other home screen managers out there that have more than 4x4 cells, such as the custom home screen manager on the Archos tablets. If you want your appwidget to work in some of these other homescreen managers that do special things like increase the number of cells on the screen or allow text input and scrolling in app widgets, then you are probably going to have to write a custom version of your widget for those home screen managers.

So the answer to your question, assuming you are always targeting the default home screen manager, is that the screen is always 4x4 cells and as long as you stick with device independent pixels you have nothing extra you need to do to make your appwidget scale and work correctly on higher resolutions.

mbaird
Thanks for your comments.One more question. For large screen and hdpi screen, is one cell still 80dip * 100dip in portrait orientation.I asked this, because I need to draw in the views in the widget. Thanks.
As far as I know the cell size is always 80dip and 100dip.
mbaird
A: 

When you use images, you have to put them with different dimensions into the related folders in your project-directory.

example: - you use 100dip width for an imageview - in folder "drawable-mdpi" you should put .png with 100px width. - in folder "drawable-hdpi" .png with 150px width - in folder "drawable-ldpi" .png with 75px width

joki