RadioGroup

  1. <RadioGroup
  2. android:id="@+id/client_charge_radiogroup"
  3. android:layout_width="200dp"
  4. android:layout_height="40dp"
  5. android:layout_marginLeft="5dp"
  6. android:layout_alignParentRight="true"
  7. android:fadingEdge="none"
  8. android:gravity="center_vertical"
  9. android:layout_centerVertical="true"
  10. android:orientation="horizontal"
  11. >
  12. <RadioButton
  13. android:id="@+id/client_radio_label"
  14. android:layout_width="0dp"
  15. android:layout_height="match_parent"
  16. android:layout_weight="1"
  17. android:button="@color/transparent"
  18. android:gravity="center"
  19. android:text="Client"
  20. android:textColor="@color/color_radiobutton"
  21. android:background="@drawable/radio_group_selector"
  22. />
  23. <RadioButton
  24. android:id="@+id/firm_radio_label"
  25. android:layout_width="0dp"
  26. android:layout_height="match_parent"
  27. android:layout_weight="1"
  28. android:button="@color/transparent"
  29. android:gravity="center"
  30. android:text="Firm"
  31. android:checked="true"
  32. android:textColor="@color/color_radiobutton"
  33. android:background="@drawable/radio_group_selector"/>
  34. </RadioGroup>

radiobutton字体颜色改变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:state_checked="false" android:color="@color/color_text_normal"/>
  6. </selector>

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

color.xml

  1. <color name="transparent">#000000</color>
  2. <color name="color_bg_selected">#e0301e</color>
  3. <color name="color_bg_normal">#e7e7e8</color>
  4. <color name="color_text_selected">#ffffff</color>
  5. <color name="color_text_normal">#000000</color>

Activity

    1. clientRadioGroup = (RadioGroup) findViewById(R.id.client_charge_radiogroup);
    2. clientRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    3. @Override
    4. public void onCheckedChanged(RadioGroup group, int checkedId) {
    5. int radioButtonId = group.getCheckedRadioButtonId();
    6. RadioButton rb = (RadioButton)findViewById(radioButtonId);
    7. String radioButtonLabel = rb.getText().toString();
    8. }
    9. });

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 选择改变字体颜色和背景颜色的更多相关文章

  1. Android 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. 使用 JavaScript 的 HTML 页面混合、根据在下拉列表框中选择的内容,决定页面效果,用户在下拉列表框中选择页面将要使用的背景颜色

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

  9. c# 设置控件的前景颜色和背景颜色

    AutoSize:设置为false取消自动计算尺寸功能,控件的大小则按照设定的Size来呈现,设置为true自动计算大小 TextAlign:设置对齐方式 // // 摘要: // 用默认的所有者运行 ...

随机推荐

  1. 比较两个序列字典序(lexicographicallySmaller)

    bool lexicographicalSmaller(vector<int> a, vector<int> b) { int n = a.size(); int m = b. ...

  2. Apple Watch: WatchKit 应用程序要点

    Apple Watch: WatchKit 应用程序要点 本文译自:Apple Watch: WatchKit App Essentials WatchKit 应用程序架构 上一篇文章简单介绍了 Wa ...

  3. 日志记录类LogHelper

    开源日志log4net使用起来很方便,但是项目中不让用,所以自己重写了一个类,用来记录日志,比较简单. 1.首先是可以把日志分成多个类型,分别记录到不同的文件中 /// <summary> ...

  4. Microsoft Excel Sheet/表格 制作折线图

    Microsoft Excel Sheet/表格 制作折线图 虽然比较简单,但是仍然需要稍微花一点功夫. 1.制作好表格数据 2.先将数据选定(不包括 横座标的 年月日或其他的刻度 的那一列) 3.插 ...

  5. hdu 4778 Gems Fight! 博弈+状态dp+搜索

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4102743.html 题目链接:hdu 4778 Gems Fight! 博弈+状态dp+搜 ...

  6. 安装Apache Web 服务器软件

    Apache下载地址:http://pan.baidu.com/s/1kTKCEOn 1: 右击安装 2: 3: 4: 5:安装成功: 6:测试在浏览器地址栏输入:localhost; 会出现一个页面 ...

  7. Linux网络应用编程之VLAN(Packet Tracer仿真)

    VLAN 一.VLAN概述 VLAN(虚拟局域网):将多个设备和用户在逻辑上联网在一起,这些设备和用户不受物理位置的限制(物理设备可以在不同的地方),但是他们的通信就好像在同一网段中一样,这就叫VLA ...

  8. 获取input标签的所有属性

    1.用jquery$("input[name='btnAdd']").attr("value") 获取value属性值,其它属性换attr的参数就OK 例1: ...

  9. C#对XML、JSON等格式的解析

    C#对XML.JSON等格式的解析 一.C#对XML格式数据的解析 1.用XMLDocument来解析 XmlDocument xmlDocument = new XmlDocument(); xml ...

  10. 对Android中dp单位的理解

    dp 设备独立像素 ,也叫dip, device independent pixle. 比如同样在1英寸大小的屏幕上,高密度的屏幕可显示100个像素点,而低密度的屏幕只能70个点. 用了dp之后,只要 ...