我有一个这样的按钮:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello"
android:textColor="@color/primary"
android:background="@drawable/button"
/>
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>
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>
我还希望在禁用按钮时更改按钮的文字颜色。如何为每个州指定不同的文字颜色?