<?XML version= "1.0" encoding= "UTF-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android"> <Itemandroid:state_selected= "true"Android:color= "@color/white" /> <Itemandroid:state_checked= "true"Android:color= "@color/white" /> <ItemAndroid:color= "@color/black" /></selector>
The official description of each state attribute is as follows:
| XML Attributes |
| Attribute Name |
Related Method |
Description |
| Android:constantsize |
|
If true, the drawable ' s reported internal size would remain constant as the state changes; The size is the maximum of the states. |
| android:state_activated |
|
State value StateListDrawable for, set when a view or its parent have been "activated" meaning the user has currently marked it as Bein g of interest. |
| Android:state_active |
|
State value for StateListDrawable . |
| Android:state_checkable |
|
State identifier indicating, the object may display a check mark. |
| Android:state_checked |
|
State identifier indicating, the object is currently checked. |
| Android:state_enabled |
|
State value StateListDrawable for, set when a view is enabled. |
| Android:state_first |
|
State value for StateListDrawable . |
| Android:state_focused |
|
State value StateListDrawable for, set when a view has input focus. |
| Android:state_last |
|
State value for StateListDrawable . |
| Android:state_middle |
|
State value for StateListDrawable . |
| Android:state_pressed |
|
State value StateListDrawable for, set if the user is pressing a view. |
| android:state_selected |
|
State value StateListDrawable for, set when a view (or one of it parents) is currently selected. |
| Android:state_single |
|
State value for StateListDrawable . |
| Android:state_window_focused |
|
State value StateListDrawable for, set when a view's window has input focus. |
| Android:variablepadding |
|
If True, allows the drawable ' s padding to change based on the current state, which is selected. |
| Android:visible |
|
Indicates whether the drawable should be initially visible. |
Note: If you have more than one item, the program will automatically match from top to bottom, and the first match will be applied. (not through Best Bets)
If an item does not have any status descriptions, it will be able to be matched by any one of the states.
Android drawable State various properties