Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

customizing a drawable for a range of APIs Android

I'd like to customize one drawable e.g. /drawable/image.png

only for APis 19 to 21. For later APIs (after 22 incl. I'd like a drawable to be different). Do I need to create directories drawable-v19, drawable-v20, drawable-v21, drawable-v22 (for the others?) ? It's a bit unclear to me how it works...

like image 812
hhg Avatar asked Apr 28 '17 08:04

hhg


1 Answers

You should only need to create directories for the versions that set a different resource. So your resources directory would look something like:

res/
    drawable/        --> SDK version below 19
        image.png
    drawable-v19/    --> SDK version between 19 and 21 (including both)
        image.png
    drawable-v22/    --> SDK version 22 and greater
        image.png

Edit: Seems to be working this way. I've set up a small project with strings.xml for sdk 19 and 22, launched two emulators, with sdk 21 and 25. The SDK 21 one showed the string in the v19 strings, and the SDK 25 the one in v22 strings. Here's a pic with the results:Andoroir version qualifires

Hope it helps. (Couldn't test it with sdk lower than 19, but that should take values from the default file, since no qualifier applies.)

like image 104
lluchmk Avatar answered Oct 16 '22 15:10

lluchmk