android自定义radiobutton样式文字颜色随选中状态而改变
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了android自定义radiobutton样式文字颜色随选中状态而改变,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2131字,纯文字阅读大概需要4分钟。
内容图文
主要是写一个 color selector
在res/建一个文件夹取名color
res/color/color_radiobutton.xml
1
<
selector
xmlns:android
="http://schemas.android.com/apk/res/android"
>
2
<
item
android:state_checked
="true"
android:color
="@color/color_text_selected"
/>
3
<!--
not selected
-->
4
<
item
android:color
="@color/color_text_normal"
/>
5
</
selector
>
程序使用:
1 //layout/main.xml 2 <? xml version="1.0" encoding="utf-8" ?> 3 < LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android" 4 android:layout_width ="fill_parent" 5 android:layout_height ="fill_parent" 6 android:orientation ="vertical" > 7 < RadioGroup 8 android:id ="@+id/radiogroup_personal_condition" 9 android:layout_width ="wrap_content" 10 android:layout_height ="wrap_content" 11 android:orientation ="horizontal" > 12 < RadioButton 13 android:id ="@+id/radiobutton_1" 14 android:layout_width ="wrap_content" 15 android:layout_height ="wrap_content" 16 android:background ="@drawable/selector_radio" 17 android:button ="@null" 18 android:checked ="true" 19 android:gravity ="center" 20 android:text ="目录" 21 android:textColor ="@color/color_radiobutton" 22 android:textSize ="@dimen/font_size" 23 android:textStyle ="bold" /> 24 < RadioButton 25 android:id ="@+id/radiobutton_2" 26 android:layout_width ="wrap_content" 27 android:layout_height ="wrap_content" 28 android:background ="@drawable/selector_radio" 29 android:button ="@null" 30 android:gravity ="center" 31 android:text ="书签" 32 android:textColor ="@color/color_radiobutton" 33 android:textSize ="@dimen/font_size" 34 android:textStyle ="bold" /> 35 </ RadioGroup > 36 </ LinearLayout >
附录,点击radio改变radio图片
1
<?
xml version="1.0" encoding="utf-8"
?>
2
<
selector
xmlns:android
="http://schemas.android.com/apk/res/android"
>
3
<
item
android:state_checked
="true"
android:drawable
="@drawable/ic_radio_checkon"
/>
4
<!--
not selected
-->
5
<
item
android:drawable
="@drawable/ic_radio_checkoff"
/>
6
7
</
selector
>
原文:http://www.cnblogs.com/xiaoliu66007/p/4815920.html
内容总结
以上是互联网集市为您收集整理的android自定义radiobutton样式文字颜色随选中状态而改变全部内容,希望文章能够帮你解决android自定义radiobutton样式文字颜色随选中状态而改变所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。