hi guys i have been developing android app that should match most of the screen resolutions. And i just got struck at setting the drawable folder for this two resolution
1. 480 x 800 with approximate density of 217
2. 540 x 960 with approximate density of 240
And i have a different set of images for both the resolutions and i have set hdpi for 540 x 960 but don't have an idea of going about the 480x800 which also falls under hdpi. After goggling found a drawable qualifier called tvdpi which supports the appr. density of 213
When i set the tvdpi qualifier to the drawable folder i get "invalid resource directory name" error
Resolution and dpi are not directly related. It just so happens that many 800x480 devices are HDPI, then can just as easily be low dpi though if the screen is big enough.
If you really need direct resolution matching you will need to target API level 13 and use available width and height qualifiers for your resources or if you need to target a lower API level than 13, create your own resource loading scheme.
You can also use a combination of density and size qualifiers but that still leaves some room for two different resolutions falling into the same bucket.
But before you pick, you need to ask yourself do you really want the same pixel size for your drawables on a 3.7" 480x800 screen as you do for a 7" 480x800 screen.
Related
Sorry. I have no idea about Android screen size HDPI, LDPI, MDPI. How can I check my flutter app in these screen size?
Create new android emulators with different pixel densities, and run the app on them. I wouldn't worry about ldpi (.1% of devices). The cutoffs are 160 dpi (mdpi), 240 dpi (hdpi), 320 dpi (xhdpi) and 480 (xxhdpi).
Generally this shouldn't be a problem as long as you specified all your sizes in dp rather than pixels. The most likely thing to want to change is images, make sure that any non-vector image looks good at multiple resolutions.
HDPI, LDPI, MDPI all refer to the pixel density of your display and not resolution of the device.
Generally when developing for multiple screen sizes you should focus more on viewport (say 360dp and 600dp as your breakpoints), then find or create new android virtual devices that match your viewport and then run your app on those devices.
Here are a few good links:
Material IO Pixel Density
Android Documentation
Android Device List
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.
If you want to know it once, you can get an app like ScreenInfo and run it. If you want to know programmatically, you can add density folders, such as values-mdpi and values-xhdpi, place an xml file in it, say whoami.xml with the following content:
<resources>
<string name="density_bucket">mdpi</string>
</resources>
And, respectively:
<resources>
<string name="density_bucket">xhdpi</string>
</resources>
and then inquire from the app:
String densityBucket = getResources().getString( R.string.density_bucket );
Hey I recognize that chart! Mostly because I created it :D. To clarify, the chart shows what dpi each density bucket is baselined to, but cannot be used to determine which density bucket a device should be classified as. That said, this illustration below shows how devices are generalized into density buckets, and you can see they may have a higher or lower dpi than the bucket they fall in.
Now to answer your question, unfortunately, there is no guaranteed way to know what density bucket a device will fall into purely based off of its specs. This is because the device manufacturer is able to choose the density bucket. Most of the time, they will choose the bucket closest to the actual dpi of the device**. Luckily, Google has gathered a list of common devices, along with their screen dimensions in dp, and density buckets. This should give you an idea of how to properly support the most prevalent screen size that are out in the wild.
**Note: Some devices have their own special density buckets. Most notably, the Nexus 7 (2012) is 213dpi (tvdpi), the Nexus 5X is 420dpi, and the Nexus 6 and 6P are 560dpi. These devices grab assets from the other density versions and scale them.
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.
what's the folder name for 1080p resource on android?
I know mdpi support 320x480
hdpi support 480x800
xhdpi support 720p
Unfortunately it isn't that easy. Mdpi, hdpi and xhdpi are all select based on screen density - basically the size of the pixels - not the number of pixels. So, if your 1080p screen is very large, it could conceivably be an mdpi screen (yes, it happens). You have the alternative to use small, normal, large and xlarge as selectors but these aren't tightly defined. A 1080p screen should be xlarge but so should a 720p.
The document at http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources is useful.
This is a poorly worded question, but it seems like you are trying to support the new 1080 x 1920 phones coming out. The maximum pixel density that Android supports is 480 dpi, which is called xxhdpi.
A phone (3"-5" diagonal) at 1080 x 1920 will fall into the xxhdpi density, like the Samsung Galaxy S4 at 441 dpi. However, a tablet (7"+) at 1080 x 1920 will not be xxhdpi, so do not assume that density correlates to resolution.
You can clear about the Screen size, density pixels in android. I found tutorial Tips for designers and developers Android
I have both hdpi and xhdpi folders in my res folder. However, android makes use of hdpi xml file for 1280 X 800 resolution of a tablet. Could it be because my xml file accesses resources which are in drawable-hdpi folder but not in drawable-xhdpi folder?
I think you are confused with DPI vs screen sizes, which resolution along does not provide. You can have a XHDPI device with a small screen that is very high resolution (such as the Galaxy S3) or a MDPI or LDPI device with a very large screen (such as when you use Android on your TV).
Generally speaking, Dot per pixel = Resolution / Screen size.
Not all android devices are set to the right density by the manufacturer, its really a hodgepodge of densities no matter what resolution you think you have, the device could still be seen by the android OS as a lower or different density than you think
if the android OS thinks your device is HDPI then it will access HDPI drawables
I want the emulator to make use of the files present in the xhdpi folder and at the same time it should have low density. My emulator is set to a resolution of 1280 X 800 similar to motorola xoom tablet. Now if i keep a density of 149 ppi, android does not access the xhdpi folder. Please help. TIA.
Do not misunderstand Screen size, Screen density and Resolution. Read this article first.