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

What is the best way to control widget size on Android?

Look at the following table:

• On the screen, 3.6-4.0 inches (smartphone) with a resolution of 480x800 pixels, dpi is 240 dpi
• On a 4.3-inch screen (smartphone) with a resolution of 540x960 pixels dpi 270 dpi
• On a 7-inch screen (tablet) with a resolution of 480x800 pixels dpi 130dpi
• On a 7-inch screen (tablet) with a resolution of 600x1024px dpi 170dpi
• On an 8.9-inch screen (tablet) with a resolution of 1280x800 / 768 pixels dpi 170dpi
• On a 10.1-inch screen (tablet) with a resolution of 1280x800 pixels dpi 150 dpi

In general, smartphones come with a much higher resolution.

Now, if I create a control with a width of 100 pixels, it will be good when displayed with low resolution, but poorly at a high level, where the control will be too small. If I create the same control with 100dp, it will be the opposite - on high-resolution displays it will scale, for example. 150 pixels, but on low resolution screens (tablets) it will still be 100 pixels or less if the density drops below 160 dpi.

So, how should I make a control that takes 4 inches on a 4-inch display on a 7-inch display, takes 1.5 inches and 1inches on a 10.1-inch display? In other words, the larger the screen, the greater the control, but without regard to resolution.

But is this really a good approach?

Regards, Stan

+4
source share
1 answer

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" /> 

as well as check the following link on the Android developer site, this can help you find a solution to your question.

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

+2
source

All Articles