的切换文本颜色要创建自定义切换按钮,我在/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>
,然后我用一个选择器来指定按钮的状态如何看待在/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>
如何修改此设置以在状态更改时切换按钮的文本颜色?
在形状范围,给你想要的颜色paremeters,并删除style.xml中的背景。 – Tugrul
我认为这个链接对你的问题很有用:http://stackoverflow.com/questions/7096599/how-to-change-the-text-color-of-an-android-tooglebutton-on-state-change – secretlm
Based在Eclipse中进行自动完成实验时,该链接不提供有效的语法。指定颜色的唯一可能方式是在<- '范围内的
'“。但它不会更改文字颜色。 –