I have 4 different sizes for each of the icons I need to use in my app. The problem is My Nexus 7 (1280 x 800) and galaxy s2 (800 x 480) seem to use the resources in drawable-hdpi. How do I force the Nexus to use resources in drawable-xhdpi and then the 10 inch tab to use drawable-xxhdpi.
I have this in my manifest file
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
You can't.
The qualifiers
hdpi,xhdpi,xxhdpi
describes the screen density of the device, not the size of screen. From the official docIf you want to support tablets also, use
large, xlarge
qualifiers. Nexus 7 is alarge-hdpi
tablet(technically it'stvdpi
, but takes images fromhdpi
). So if you want to put images for Nexus 7, make a folder nameddrawable-large-hdpi
and put the images there.Note: This is the special case for Nexus 7. Because even though Nexus 7 is a 7 inch tablet, it has resolution of 1280 * 800. So it's an
hdpi
device. But normal 7 inch devices have lower resolutions of 1024 * 600. So they aremdpi
devices. So the drawable qualifier can change. (From my own experience, first put a folderdrawable-large-mdpi
for 7 inch devices and check it on Nexus 7. If there is no problem with images, you dont have to put another folder. Because if a particular folder is not present, Android will check for the nearest possible folder and optimize it for the device screen)Now regarding the 10 inch tablets case, they are
xlarge
devices and their densities can change frommdpi
toxhdpi
(Nexus 10). But many have resolution of 1280 * 800 and they aremdpi
devices.The better practice is to put the following drawables
Try to use
Configuration qualifiers
for your resources. This is the best practice. Likeres/drawable-normal-hdpi-port/icon.png
.Ref Link: Configuration qualifiers
Thanks.
that depends upon device like
nexus 7
has240dpi
which is ahdpi
device it will take drawable resources from hdpi like this if you test the same insamsung
tab 2
it will take the same drawable frommdpi
because its a mdpi device