主要是写一个 color selector

在res/建一个文件夹取名color

res/color/color_radiobutton.xml

  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:color="@color/color_text_selected"/>
  4. <!-- not selected -->
  5. <item android:color="@color/color_text_normal"/>
  6. </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>

android 自定义 radiobutton 文字颜色随选中状态而改变的更多相关文章

  1. android自定义radiobutton样式文字颜色随选中状态而改变

    主要是写一个 color selector 在res/建一个文件夹取名color res/color/color_radiobutton.xml <selector xmlns:android= ...

  2. Android自定义radiobutton(文字靠左,选框靠右)

    <RadioButton android:id="@+id/rb_never" android:layout_width="fill_parent" an ...

  3. Android 自定义RadioButton实现

    由于使用小米系统MIUI运行是RadioButton样式跟google Android API自定义的不一样,则我们可以定义任何想要的东东.没有做不到,只有想不到 Android 自定义RadioBu ...

  4. Android 自定义RadioButton的样式

    Android 自定义RadioButton的样式 我们知道Android控件里的button,listview可以用xml的样式自定义成自己希望的漂亮样式. 最近用到RadioButton,利用xm ...

  5. android 自定义进度条颜色

    android 自定义进度条颜色 先看图 基于产品经理各种自定义需求,经过查阅了解,下面是自己对Android自定义进度条的学习过程!   这个没法了只能看源码了,还好下载了源码, sources\b ...

  6. 带你体验Android自定义圆形刻度罗盘 仪表盘 实现指针动态改变

    带你体验Android自定义圆形刻度罗盘 仪表盘 实现指针动态改变 转 https://blog.csdn.net/qq_30993595/article/details/78915115   近期有 ...

  7. 转:android 自定义RadioButton样式

    http://gundumw100.iteye.com/blog/1146527  上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用Ra ...

  8. Android 自定义RadioButton样式

     上面这种3选1的效果如何做呢?用代码写? 其实有更简单的办法,忘了RadioButton有什么特性了吗? 我就用RadioButton实现了如上效果,其实很简单的. 首先定义一张background ...

  9. Android Textview实现文字颜色渐变效果

    最近做应用的时候遇到一个需求,一行文字的颜色需要一个渐变效果 如上所有 从左到有逐渐变化,自己写了一个demo实现上述效果 package com.huwei.example.test; import ...

随机推荐

  1. 动态执行linq 语句 NLinq

    using Evaluant.NLinq.Memory;using System.Collections.Generic;using Evaluant.NLinq;using System.Colle ...

  2. ndk文件操作问题及小结

    最近在做文件传输,发现在android下用f系列的C库函数去读取文件文件大小会受到2G大小的约束,查阅了很久,最后只能去看google的libc源码,发现了以下几个问题: 1.bionic的libc是 ...

  3. PHP图像操作:3D图、缩放、旋转、裁剪、添加水印(三)

    来源:http://www.ido321.com/887.html 5.PHP对图像的旋转 1: <div> 2: <h4>旋转之前</h4> 3: <img ...

  4. Tkinter教程之Canvas篇(3)

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811922 ''Tkinter教程之Canvas篇(3)''''''16.移动item'''# ...

  5. Jquery类级别与对象级别插件开发

    jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法.jQuery的全局函数就是属于jQuery命名空间的函数,另一种是对象级 ...

  6. Hibernate之HQL查询

    一.Hibernate 提供了以下几种检索对象的方式: 导航对象图检索方式: 根据已经加载的对象导航到其他对象 OID 检索方式: 按照对象的 OID 来检索对象 HQL 检索方式:使用面向对象的 H ...

  7. PC问题-VMware Workstation出现“文件锁定失败”

    问题现象:电脑关机时挂起VMware Workstation后,第二天运行VMware Workstation出现“文件锁定失败”. 问题原因:在WIN的目录中有*.LCK文件,此文件是用来锁定当前虚 ...

  8. hdu 5363 Key Set

    http://acm.hdu.edu.cn/showproblem.php?pid=5363 Key Set Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  9. HTTP协议状态码详解

    HTTP状态码,我都是现查现用. 我以前记得几个常用的状态码,比如200,302,304,404, 503. 一般来说我也只需要了解这些常用的状态码就可以了.  如果是做AJAX,REST,网络爬虫, ...

  10. HDU 2795 Billboard (线段树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 题目大意:有一块h*w的矩形广告板,要往上面贴广告;   然后给n个1*wi的广告,要求把广告贴 ...