Setting drawable folder to use for different resolutions

How do I force the Nexus to use resources in drawable-xhdpi and then
the 10 inch tab to use drawable-xxhdpi?

You can’t.

The qualifiers hdpi,xhdpi,xxhdpi describes the screen density of the device, not the size of screen.
From the official doc

Screen density

The quantity of pixels within a physical area of the screen; usually
referred to as dpi (dots per inch). For example, a “low” density
screen has fewer pixels within a given physical area, compared to a
“normal” or “high” density screen. For simplicity, Android groups all
actual screen densities into four generalized densities: low, medium,
high, and extra high.

If you want to support tablets also, use large, xlarge qualifiers. Nexus 7 is a large-hdpi tablet(technically it’s tvdpi, but takes images from hdpi). So if you want to put images for Nexus 7, make a folder named drawable-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 are mdpi devices. So the drawable qualifier can change. (From my own experience, first put a folder drawable-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 from mdpi to xhdpi(Nexus 10). But many have resolution of 1280 * 800 and they are mdpi devices.

The better practice is to put the following drawables

// for Phones
drawable-ldpi
drawable-mdpi
drawable-hdpi

//for 7 inch tablets
drawable-large-mdpi
drawable-large-hdpi(for Nexus 7)

// for 10 inch tablets
drawable-xlarge-mdpi

Leave a Comment