October 2018
Intermediate to advanced
464 pages
15h 17m
English
In this recipe, we are using the Android resource selection process to assign the appropriate theme (which is a resource) based on the API version. Since we need to choose the theme based on the OS version in which it was released, we created two new values folders specifying the API version. This gives us a total of three styles.xml files: the default style, one in the values-v11 directory, and the last in the values-v21 directory.
Notice the same theme name is defined in all three styles.xml files. This is how the resource selection works. Android will use the resource from the directory that best fits our values. Here we are using the API level, but other criteria are available as well. It is very common to define separate ...