Color State List Resource - Android Studio

Color State List Resource

A ColorStateList is an object you can define in XML that you can apply as a color, but will actually change colors, depending on the state of the View object to which it is applied. For example, aButton widget can exist in one of several different states (pressed, focused, or neither) and, using a color state list, you can provide a different color during each state.You can describe the state list in an XML file.Eachcolor is defined in an element inside a single element.

FILE LOCATION:

res/color/filename.xml
The filename will be used as the resource ID.

RESOURCE REFERENCE:

In Java: R.color.filename
In XML: @[package:]color/filename

Syntax

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
        android:color="hex_color"
        android:state_pressed=["true" | "false"]
       android:state_focused=["true" | "false"]
       android:state_selected=["true" | "false"]
       android:state_checkable=["true" | "false"]
      android:state_checked=["true" | "false"]
      android:state_enabled=["true" | "false"]
      android:state_window_focused=["true" | "false"]/>
     </selector>
I hope it helps. Thanks for being here! See you in the next code snippet post!
Comment via Facebook
0 Comment via Google

0 تعليقات:

Post a Comment