How to calculate appropriate android widget size?
I have Android widget that contains two buttons. But i have no idea how big my widget should be for different DPI. According to this, it's easy to calculate, but my widget isn't square, it's rectangle, how to calculate开发者_如何学编程 it's size?
My widget-provider.xml looks like this:
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="160dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
android:initialLayout="@layout/main"
/>
I would take a look at the widget design guidelines, specifically the section about widget sizes. It specifies the size in px, but you should be able to convert them to dp for a given density.
Since you're using dip units, it will be automatically scaled by the system according to the pixel density. (The widget will always be scaled to the same physical size, regardless of pixel density.) The reference density that the system uses for scaling is 160 pixels/inch.
精彩评论