
现在,我需要更改切换按钮文本(红/白)的颜色.
使用xml我只是无法让它工作,也许任何人有一个想法我做错了什么?
我的按钮在布局xml中:
<Togglebutton androID:paddingRight="20dip" androID:ID="@+ID/pseudo_tab_right" androID:layout_weight=".50" androID:layout_wIDth="wrap_content" androID:textStyle="bold" androID:paddingleft="10dip" androID:textSize="12sp" androID:layout_height="wrap_content" androID:textcolor="@drawable/pseudo_tab_text_color"androID:textOff="@string/pseudo_tab_right_text"androID:textOn="@string/pseudo_tab_right_text"androID:background="@drawable/tab_button_right" />
按钮状态的xml:
<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID"><item androID:state_checked="true" androID:drawable="@drawable/sort_button_red_right_43" /> <item androID:drawable="@drawable/sort_button_white_right_43" /></selector>
而xml为颜色:
<?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="#4f5459" /> <!-- focused --><item androID:state_focused="true" androID:color="#4f5459" /><!-- default --><item androID:color="#ffffff" /> <!-- trying these out,but none works --><item androID:state_checked="true" androID:color="#ff0000" /><item androID:state_enabled="true" androID:color="#ff00dd" /><item androID:state_selected="true" androID:color="#ff00dd" /><item androID:state_active="true" androID:color="#ff00dd" /></selector>解决方法 找到了:
现在我正在使用androID:state_checked =“true”和androID:state_checked =“false”.
颜色的XML:
<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <item androID:state_checked="true" androID:color="#ffffff" /> <item androID:state_checked="false" androID:color="#000000" /></selector>总结
以上是内存溢出为你收集整理的如何更改Android ToogleButton的状态变化的文字颜色?全部内容,希望文章能够帮你解决如何更改Android ToogleButton的状态变化的文字颜色?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)