Slightly noob-ish question but I get confused when it comes to calculating what density bucket the phone falls in. I'll take my Galaxy S3 as an example.
It has a resolution of 1280 x 720
which means it has 306 dpi
. Now, referring to the chart below, my phone falls in the hdpi
category because it has more than 240 dpi
but less than the 320 dpi
needed to be an xhdpi
screen. So, the phone is 853 x 480 DP
(dividing by 1.5)
However, a screen information app on my phone tells me that it is an xhdpi
screen. So, the phone is 640 x 360 DP
(dividing by 2).
How do I know what correct density bucket my phone falls in?
Update:
I am trying to design my app for the top 10 Android phones in my country. So I am calculating their sizes in DPs to design UIs based on their "smallest width DPs". This isn't a one-off size calculation.
I think Android tries to find the "best match". So if 306 is in between 240 and 320, its much more closer to 320. So it will use xhdpi. You can read more here. Quoting from the official link to docs:
Based on the size and density of the current screen, the system uses any size- and density-specific resource provided in your application. For example, if the device has a high-density screen and the application requests a drawable resource, the system looks for a drawable resource directory that best matches the device configuration. Depending on the other alternative resources available, a resource directory with the hdpi qualifier (such as drawable-hdpi/) might be the best match, so the system uses the drawable resource from this directory.