To create a custom ToggleButton, I've defined a new style in /res/values/styles.xml
:
<style name="myToggleButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#000000</item>
<item name="android:background">@drawable/my_toggle_button</item>
</style>
and I then use a selector to specify how the button's states look in /res/drawable/my_toggle_button.xml
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape>
[...]
</shape>
</item>
<item android:state_checked="false"
<shape>
[...]
</shape>
</item>
</selector>
How can I modify this setup to toggle the text color of the button when the state changes?