customizing a drawable for a range of APIs Android

社会主义新天地 提交于 2019-12-02 02:16:34

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:

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.)

You can create drawable folders like drawable-v19, drawable-v20, drawable-v21, drawable-v22 for each custom images for each versions. If the app is running on one of these devices it picks from these matching version custom respective folders or else falls back to the generic drawable folder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!