I have an image I’d like to use as a background pattern for one of my views. As a pattern, it gets tiled and thus is resolution-independent: I’d like one pixel in the image to show up as one pixel on the screen, no scaling, regardless of the device’s pixel density.
Now, I can certainly do that by making four identical copies of the image and dropping them in my mdpi, ldpi, hdpi, and xhdpi directories. But that seems redundant and bloated. Is there any way to tell the SDK to simply use the one image, as is, in every case?
Thanks.
Yes! You can either put it in an unadorned
drawabledirectory (sibling to your density-specified ones) or, more correctly, put it indrawable-nodpiand omit it from any other drawable directory.The system will always look for the best match, and if there’s no match for a particular density/size/etc. combination, it falls back to the next best until it lands in either the unqualified resource directory or (in your case) the one that says it’s for all DPIs.