RadioGroup

    <RadioGroup
android:id="@+id/client_charge_radiogroup"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_alignParentRight="true"
android:fadingEdge="none"
android:gravity="center_vertical"
android:layout_centerVertical="true"
android:orientation="horizontal"
> <RadioButton
android:id="@+id/client_radio_label"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=""
android:button="@color/transparent"
android:gravity="center"
android:text="Client"
android:textColor="@color/color_radiobutton"
android:background="@drawable/radio_group_selector"
/> <RadioButton
android:id="@+id/firm_radio_label"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=""
android:button="@color/transparent"
android:gravity="center"
android:text="Firm"
android:checked="true"
android:textColor="@color/color_radiobutton"
android:background="@drawable/radio_group_selector"/>
</RadioGroup>

radiobutton字体颜色改变color_radiobutton.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="@color/color_text_selected"/>
<!-- not selected -->
<item android:state_checked="false" android:color="@color/color_text_normal"/>
</selector>

radiobutton背景颜色改变radio_group_selector.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="@color/color_bg_selected" ></item>
<item android:state_checked="false" android:drawable="@color/color_bg_normal"></item>
</selector>

color.xml

    <color name="transparent">#</color>
<color name="color_bg_selected">#e0301e</color>
<color name="color_bg_normal">#e7e7e8</color>
<color name="color_text_selected">#ffffff</color>
<color name="color_text_normal">#</color>

Activity

        clientRadioGroup = (RadioGroup) findViewById(R.id.client_charge_radiogroup);
clientRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int radioButtonId = group.getCheckedRadioButtonId();
RadioButton rb = (RadioButton)findViewById(radioButtonId);
String radioButtonLabel = rb.getText().toString();
}
});

Android RadioGroup的RadioButton 选择改变字体颜色和背景颜色的更多相关文章

  1. RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色

    RadioGroup <RadioGroup android:id="@+id/client_charge_radiogroup" android:layout_width= ...

  2. 转 Android RadioButton设置选中时文字和背景颜色同时改变

    主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...

  3. Android RadioButton设置选中时文字和背景颜色同时改变

    主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...

  4. 使用 JavaScript 中的 document 对象的属性,根据下拉框中选择的属性,更改页面中的字体颜色和背景颜色

    查看本章节 查看作业目录 需求说明: 使用 JavaScript 中的 document 对象的属性,根据下拉框中选择的属性,更改页面中的字体颜色和背景颜色 实现思路: 在页面的 <body&g ...

  5. Sublime Text3自定义全部字体大小、字体类型和背景颜色

    一.定义侧栏的背景颜色.字体大小和间距 Sublime Text3的Afterglow主题链接为:https://github.com/YabataDesign/afterglow-theme 1.按 ...

  6. MFC 如何改变对话框的默认背景颜色(转)

    下面介绍三种方法:实现改变对话框的默认背景颜色:   (1)可以在CLotteryApp::InitInstance()设置更新对话框的背景颜色       调用SetDialogBkColor(RG ...

  7. 在wpf datagrid中,想要根据一个条件来改变datagrid行的背景颜色

    原文:在wpf datagrid中,想要根据一个条件来改变datagrid行的背景颜色 在wpf datagrid中,想要根据一个条件来改变datagrid行的背景颜色 例如根据学生的年龄来修改,年龄 ...

  8. android中设置ListView的选中的Item的背景颜色

    ListView中没有默认的选择颜色,只有选择Item后的焦点颜色,鼠标点击时Item有颜色,放开鼠标后颜色也就没有了,要实现放开鼠标后选择项的背景还是有颜色的. 1.配置main.xml <? ...

  9. 使用 JavaScript 的 HTML 页面混合、根据在下拉列表框中选择的内容,决定页面效果,用户在下拉列表框中选择页面将要使用的背景颜色

    查看本章节 查看作业目录 需求说明: 根据在下拉列表框中选择的内容,决定页面效果 用户在下拉列表框中选择页面将 要使用的背景颜色 当用户选择橙色时,页面背景将显示为橙色 实现思路: 用表单 <s ...

随机推荐

  1. 洛谷 P1724 东风早谷苗

    洛谷 P1724 东风早谷苗 题目描述 在幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆,当然有了与以往不同的功能了,那就是它能够自动行走, ...

  2. SpringBoot+springmvc异步处理请求

    有两种情况,第一种是业务逻辑复杂,但不需要业务逻辑的结果,第二种是需要返回业务逻辑的处理结果 第一种比较简单,利用多线程处理业务逻辑,或者利用spring中@Asyn注解更简单, 使用@Asyn注解, ...

  3. PatentTips - Interrupt redirection for virtual partitioning

    BACKGROUND The present disclosure relates to the handling of interrupts in a environment that utiliz ...

  4. tomcat的一些简单配置

    一.管理tomcatusernamepassword conf文件夹下,tomcat-users.xml <span style="font-size:24px;">& ...

  5. go package的理解

    golang package是基本的管理单元, 同一个package下面,可以有非常多的不同文件,只要 每个文件的头部    都有 如 "package xxx" 的相同name, ...

  6. 浅谈Normalize.css

    浅谈Normalize.css 一.总结 1.Normalize.css:它在默认的HTML元素样式上提供了跨浏览器的高度一致性,花了几百个小时来努力研究不同浏览器的默认样式的差异. 2.优于rese ...

  7. JS错误记录 - 按左右箭头div移动、一串div跟着鼠标移动

    本次练习错误总结: 1. div跟着用户操作而移动,首先必须要绝对定位,否则无法移动. 2. if条件语句里面是双等号,不是单等号(赋值). 3. 坐标值没有Right,只能offsetLeft 加减 ...

  8. POJ 3617 Best Cow Line ||POJ 3069 Saruman's Army贪心

    带来两题贪心算法的题. 1.给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下面两个操作:1.从S的头部删除一个字符,加到T的尾部.2.从S的尾部删除一个字符,加 ...

  9. PythonNET网络编程1

    # PythonNET 网络编程 ISO(国际标准化组织) 制定了 OSI(Open System Interconnectio),意为开放式系统互联.国际标准化组织(ISO)制定了OSI模型,该模型 ...

  10. vagrant 的安装与使用

    1. 安装 ubuntu 安装vagrant过程 ubuntu 安装 vagrant 时需要首先安装 virtualbox: (1)下载安装与当前 ubuntu 版本相适应的 virtualbox 安 ...