android 自定义 radiobutton 文字颜色随选中状态而改变
生活随笔
收集整理的這篇文章主要介紹了
android 自定义 radiobutton 文字颜色随选中状态而改变
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
from:http://blog.csdn.net/hpccn/article/details/7591662 先看效果 <?xml?version="1.0"?encoding="utf-8"?>?? <selector?xmlns:android="http://schemas.android.com/apk/res/android">?? ?? ?? ????<item?android:state_checked="true"?android:color="@color/color_text_selected"/>?? ????<!--?not?selected?-->?? ????<item?android:color="@color/color_text_normal"/>?? ?? ?? </selector>??
//layout/main.xml?? <?xml?version="1.0"?encoding="utf-8"?>?? <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"?? ????android:layout_width="fill_parent"?? ????android:layout_height="fill_parent"?? ????android:orientation="vertical"?>?? ????<RadioGroup?? ????????android:id="@+id/radiogroup_personal_condition"?? ????????android:layout_width="wrap_content"?? ????????android:layout_height="wrap_content"?? ????????android:orientation="horizontal"?>?? ????????<RadioButton?? ????????????android:id="@+id/radiobutton_1"?? ????????????android:layout_width="wrap_content"?? ????????????android:layout_height="wrap_content"?? ????????????android:background="@drawable/selector_radio"?? ????????????android:button="@null"?? ????????????android:checked="true"?? ?????????????android:gravity="center"?? ?????????????android:text="目錄"?? ????????????android:textColor="@color/color_radiobutton"?? ????????????android:textSize="@dimen/font_size"?? ????????????android:textStyle="bold"?/>?? ????????<RadioButton?? ????????????android:id="@+id/radiobutton_2"?? ????????????android:layout_width="wrap_content"?? ????????????android:layout_height="wrap_content"?? ????????????android:background="@drawable/selector_radio"?? ????????????android:button="@null"?? ?????????????android:gravity="center"?? ?????????????android:text="書簽"?? ????????????android:textColor="@color/color_radiobutton"?? ????????????android:textSize="@dimen/font_size"?? ????????????android:textStyle="bold"?/>?? ????</RadioGroup>?? </LinearLayout>??
主要是寫一個 color selector
在res/建一個文件夾取名color
res/color/color_radiobutton.xml
程序中就可以直接使用了
轉(zhuǎn)載于:https://www.cnblogs.com/zsw-1993/archive/2012/11/05/4880675.html
總結(jié)
以上是生活随笔為你收集整理的android 自定义 radiobutton 文字颜色随选中状态而改变的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 设为首页、加入收藏 兼容代码
- 下一篇: AjaxPro新发现-错误处理