Now that we have two Icons (Dark and Light) as described in ActionBar Icon Guide.
@drawable/ic_search_light
@drawable/ic_search_dark
How t
There's a way to define android drawables (and many other elements found in res/values) to be Theme dependent.
Lets suppose we have two drawables, menu icons in this case:
res/drawable/ic_search_light.png
res/drawable/ic_search_dark.png
And we want to use ic_search_dark.png for Application theme which is default Theme or extends it, Similarly, we want ic_search_light.png if our Application theme changes to default Theme.Light or some theme extending it.
Define a general attribute with a unique name in /res/attrs.xml like:
This is a global attribute and format type is reference, In case of a Custom View it can be defined along with style-able attributes:
Next, define two Themes, extending default Theme and Theme.Light (or themes that inherit from these) in res/styles.xml or res/themes.xml:
Finally, use the reference attribute we define to refer to these icons. In this case, we use while defining a menu layout
?attr refers to an attribute of current theme in use.
Now, we can use above two themes for application:
or
and corresponding resources will be used accordingly.
Theme can also be applied in Code, by setting it at the very beginning of Activity's onCreate().
UPDATE
Method to access these theme dependent resources from code is explained in this answer.