主要是写一个 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. POJ 1064 Cable master

    Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37865   Accepted: 8051 Des ...

  2. 火狐和google游览器的 hack独有识别 css

    先来看google的: /* 这针对于webkit内核的游览器.包括苹果谷歌游览器等*/ @media screen and (-webkit-min-device-pixel-ratio:0) { ...

  3. 如何清除win7开机密码

    一.电脑已经登录到系统,但是忘记了密1对于这种情况是最简单的,其实只需要将密码取消就可以了右键单击桌面上我的电脑,选择管理即可进入计算机管理界面2依次展开系统工具--本地用户和组--用户,在右侧选择要 ...

  4. HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632

    http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...

  5. Jmeter教程

    博客园 http://www.cnblogs.com/yangxia-test/category/431240.html 1)分析能力没有LoadRunner详细 2)jmeter不支持IP欺骗,而L ...

  6. linux交叉环境的搭建以及嵌入式开发概述

    嵌入式开发概述 由嵌入式本身的特性所影响,嵌入式系统开发与通用系统的开发有很大的区别,嵌入式的开发分为系统总体开发,嵌入式硬件开发,嵌入式系统软件开发3大部分 在系统总体开发中,由于嵌入式系统与硬件依 ...

  7. sublime text2中ctags安装问题的解决

    其实按照http://blog.csdn.net/xiao_qiang_/article/details/9074557基本可以安装好,不过我还是遇到了问题.说一下我如何解决在MAC上安装时的奇葩问题 ...

  8. PHP:6种GET和POST请求发送方法

    在i94web博客中,我试过了畅言和多说两种社会化评论框,后来还是抛弃了畅言,不安全. 无论是畅言还是多说,我都需要从远程抓取文章的评论数,然后存入本地数据库.对于多说,请求的格式如下: // 获取评 ...

  9. WinDriver&amp;PCIE

    1.安装VS2012 安装VS2012略过,主要用它来做数据传输应用程序的,WINDRIVER提供了一系列API接口,方便了用户,使用户能直接进入用户态的编程,因为内核态的编程它已做好,不需要进行修改 ...

  10. JAVA与多线程开发(线程基础、继承Thread类来定义自己的线程、实现Runnable接口来解决单继承局限性、控制多线程程并发)

    实现线程并发有两种方式:1)继承Thread类:2)实现Runnable接口. 线程基础 1)程序.进程.线程:并行.并发. 2)线程生命周期:创建状态(new一个线程对象).就绪状态(调用该对象的s ...