Articles → Android → Color state list resources in android

Color state list resources in android






What is color state list resource?







How to add a new file?









Click to Enlarge




Click to Enlarge


Adding selector




<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <!--pressed-->
    <item android:state_pressed="true" android:color="#FF0000"></item>
    <!-- default -->
    <item android:color="#228B22"/>
</selector>



Add selector in button




<Button    
                android:id="@+id/button11"    
                android:layout_width="match_parent"    
                android:layout_height="wrap_content"    
                android:text="Button" 
                android:textColor="@color/color_one" />





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, October 31, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250