6

I have a button like this:

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Hello"
    android:textColor="@color/primary"
    android:background="@drawable/button"
    />

The drawable button.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"
        android:drawable="@drawable/button_disabled" />
    <item android:drawable="@drawable/button_default" />
</selector>

The drawable button_disabled.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="@color/white"/>
</shape>

I also want to change the text color of the button when it's disabled. How do I specify a different text color for each state?

user5447353
  • 147
  • 2
  • 4

0 Answers0