Define a color state list

suggest change

Color state lists can be used as colors, but will change depending on the state of the view they are used for.

To define one, create a resource file in res/color/foo.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="">
    <item android:color="#888888" android:state_enabled="false"/>
    <item android:color="@color/lightGray" android:state_selected="false"/>
    <item android:color="@android:color/white" />

Items are evaluated in the order they are defined, and the first item whose specified states match the current state of the view is used. So it’s a good practice to specify a catch-all at the end, without any state selectors specified.

Each item can either use a color literal, or reference a color defined somewhere else.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents