开发者

Scaling widget on Android (dp, px, screen size)

what is the best way for controlling the size of widget on Android?

Look on following table:

• On 3.6-4.0 inch screen (smartphone) with 480x800px the dpi is about 240dpi

• On 4.3 inch screen (smartphone) with 540x960px the dpi is about 270dpi

• On 7 inch screen (tablet) with 480x800px the dpi is about 130dpi

• On 7 inch screen (tablet) with 600x1024px the dpi is about 170dpi

• On 8.9 inch screen (tablet) with 1280x800/768px the dpi is about 170dpi

• On开发者_开发知识库 10.1 inch screen (tablet) with 1280x800px the dpi is about 150dpi

So in general smartphones comes with much higher dpi.

Now if I create a control with 100px width it will be good on low dpi displays but bad on high, where the control will be too small. If I create the same control with 100dp it will be opposite – on high resolution displays it will scale to e.g. 150 px, but on low dpi screens (tablets) it will be still 100px or smaller is the density falls below 160dpi.

So how I should make a control that on 4inch display occupy 1inch on 7inch display occupy 1.5inch and on the 10.1inch display occupy 1inches? In other words – bigger screen size, the bigger is the control, but without considering the resolution.

But is that in fact a good approach?

Regards, SteN


Please include this in your android manifest file..

 <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:resizeable="true"
        android:anyDensity="true"
        />

and also check the following link from android developer site, this may help you in finding a rite solution for your question..

http://developer.android.com/guide/practices/screens_support.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜