RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色
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="1"
- 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="1"
- 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">#000000</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">#000000</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();
- }
- });
http://blog.csdn.net/zzf112/article/details/20467957
--------------------->
android:background="@drawable/drawlist"--------->不能用colorlist
radiogroup------->radiobutton必须要有id否则会两个都选中
<RadioGroup
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal" > <RadioButton
android:id="@+id/radio0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/zuowei"
android:button="@null"
android:checked="true"
android:gravity="center"
android:text="座位安排"
android:textColor="#ffffff" /> <RadioButton
android:id="@+id/radio1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/zuowei"
android:button="@null"
android:gravity="center"
android:text="菜单编辑"
android:textColor="#ffffff" />
</RadioGroup>
RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色的更多相关文章
- Android RadioGroup的RadioButton 选择改变字体颜色和背景颜色
RadioGroup <RadioGroup android:id="@+id/client_charge_radiogroup" android:layout_width= ...
- 转 Android RadioButton设置选中时文字和背景颜色同时改变
主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...
- Android RadioButton设置选中时文字和背景颜色同时改变
主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...
- 使用 JavaScript 中的 document 对象的属性,根据下拉框中选择的属性,更改页面中的字体颜色和背景颜色
查看本章节 查看作业目录 需求说明: 使用 JavaScript 中的 document 对象的属性,根据下拉框中选择的属性,更改页面中的字体颜色和背景颜色 实现思路: 在页面的 <body&g ...
- Sublime Text3自定义全部字体大小、字体类型和背景颜色
一.定义侧栏的背景颜色.字体大小和间距 Sublime Text3的Afterglow主题链接为:https://github.com/YabataDesign/afterglow-theme 1.按 ...
- MFC 如何改变对话框的默认背景颜色(转)
下面介绍三种方法:实现改变对话框的默认背景颜色: (1)可以在CLotteryApp::InitInstance()设置更新对话框的背景颜色 调用SetDialogBkColor(RG ...
- 在wpf datagrid中,想要根据一个条件来改变datagrid行的背景颜色
原文:在wpf datagrid中,想要根据一个条件来改变datagrid行的背景颜色 在wpf datagrid中,想要根据一个条件来改变datagrid行的背景颜色 例如根据学生的年龄来修改,年龄 ...
- 使用 JavaScript 的 HTML 页面混合、根据在下拉列表框中选择的内容,决定页面效果,用户在下拉列表框中选择页面将要使用的背景颜色
查看本章节 查看作业目录 需求说明: 根据在下拉列表框中选择的内容,决定页面效果 用户在下拉列表框中选择页面将 要使用的背景颜色 当用户选择橙色时,页面背景将显示为橙色 实现思路: 用表单 <s ...
- c# 设置控件的前景颜色和背景颜色
AutoSize:设置为false取消自动计算尺寸功能,控件的大小则按照设定的Size来呈现,设置为true自动计算大小 TextAlign:设置对齐方式 // // 摘要: // 用默认的所有者运行 ...
随机推荐
- 一致性Hash算法及使用场景
一.问题产生背景 在使用分布式对数据进行存储时,经常会碰到需要新增节点来满足业务快速增长的需求.然而在新增节点时,如果处理不善会导致所有的数据重新分片,这对于某些系统来说可能是灾难性的. 那 ...
- 高级C#
使用delegates委托写插件方法: public delegate int Transformer (int x); public class Util { public static void ...
- ping 命令详解
Linux系统的ping命令是常用的网络命令,它通常用来测试与目标主机的连通性,我们经常会说"ping一下某机器,看是不是开着".不能打开网页时会说"你先ping网关地址 ...
- JavaScript学习笔记(1)——JavaScript简介
JavaScript一种解释性脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型.它的解释器被称为JavaScript引擎,该引擎为浏览器的一部分.JavaScript最早是用 ...
- 02_HttpClient_Get请求
[实例1. GET请求百度(乱码)] /** * Http GET请求百度,但是返回乱码 */ public static void main(String[] args) throws Except ...
- IO流03_流的分类和概述
[概述] Java的IO流是实现输入/输出的基础,它可以方便的实现数据的输入/输出操作. Java中把不同的输入/输出源(键盘.文件.网络连接)抽象表述为"流"(Stream). ...
- HTML5之Canvas画布
先上代码: <canvas width="1000" height="800">浏览器不支持HTML5!</canvas> <sc ...
- svn 项目转移
http://www.cnblogs.com/techMichaelLee/p/3193197.html (参考) svnadmin dump /home/svn/project > /home ...
- Linux C 程序 空语句-gcc编译命令(SIX)
C语言语句1.空语句:当一个if或者while判断部分能完成工作,空语句可以用来表示if或者while内的空循环体 if(a == b ); 2.gcc编译器 //程序的编译过程: // 预处理:pr ...
- 用PHP实现单向链表
供参考,代码还可继续打磨 同时放在了我的github上:https://github.com/hheedat/demo/blob/master/learn_php/58_linked_list.php ...