radioGroup这控件在开发中也是常用到的

RadioGroup 有时候比较有用.主要特征是给用户提供多选一机制。

用微信举一个例子吧!

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="horizontal"
android:background="#383A37"
> <TextView
android:id="@+id/textView1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="18sp"
android:text="@string/weixin" /> <TextView
android:id="@+id/textView2"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/blank" /> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical|center_horizontal"> <ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
android:gravity="center_vertical"
android:src="@drawable/fdj"
android:layout_marginRight="10dp"/> <ImageView
android:id="@+id/imageView2"
android:layout_width="30dp"
android:layout_height="30dp"
android:gravity="center_vertical"
android:src="@drawable/barbuttonicon_add"
android:layout_marginRight="10dp" />
</LinearLayout> </LinearLayout>

head.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" > <RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
> <RadioButton
android:id="@+id/radio0"
android:checked="true"
style="@style/radioStyle"
android:drawableTop="@drawable/radio_weixin_check"
android:textColor="@drawable/radio_color_check"
android:text="@string/weixin" /> <RadioButton
android:id="@+id/radio1"
style="@style/radioStyle"
android:drawableTop="@drawable/radio_tongxunlu_check"
android:textColor="@drawable/radio_color_check"
android:text="@string/tongxunlu" /> <RadioButton
android:id="@+id/radio2"
style="@style/radioStyle"
android:drawableTop="@drawable/radio_faxian_check"
android:textColor="@drawable/radio_color_check"
android:text="@string/faxian" /> <RadioButton
android:id="@+id/radio3"
style="@style/radioStyle"
android:drawableTop="@drawable/radio_wo_check"
android:textColor="@drawable/radio_color_check"
android:text="@string/wo" />
</RadioGroup> </LinearLayout>

下面是微信底部的文件

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:color="#A0A0A0"></item>
<item android:state_checked="true" android:color="#45C01b"></item>
</selector>
 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:drawable="@drawable/tabbar_discover"></item>
<item android:state_checked="true" android:drawable="@drawable/tabbar_discoverhl"></item>
</selector>

后三个同上就不展开了

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:drawable="@drawable/tabbar_mainframe"></item>
<item android:state_checked="true" android:drawable="@drawable/tabbar_mainframehl"></item>
</selector>

radio_weixin_check

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:drawable="@drawable/tabbar_me"></item>
<item android:state_checked="true" android:drawable="@drawable/tabbar_mehl"></item>
</selector>

radio_wo_check

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:drawable="@drawable/tabbar_contacts"></item>
<item android:state_checked="true" android:drawable="@drawable/tabbar_contacts_hl"></item>
</selector>

radio_tongxunlu_check

mainXML配置

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.main.weixin.MainActivity" > <!-- 头部 -->
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
> <include layout="@layout/head"/> </LinearLayout> <!-- 中间 -->
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"> <include layout = "@layout/listview_layout"></include> </LinearLayout> <!-- 尾部 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
> <include layout="@layout/bottom"/> </LinearLayout>
</LinearLayout>

效果如下

android之RadioGroup的更多相关文章

  1. Android自定义控件----RadioGroup实现APP首页底部Tab的切换

    ​[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...

  2. android学习--radiogroup学习

    这个阶段在学习android的相关基本UI现将相关练习的代码粘贴在此便于后期学习之用(radio控件) 效果图:   main_layout.xml <?xml version="1. ...

  3. Android 使用RadioGroup和RadioButton实现单选效果

    RadioButton和CheckBox的区别:CheckBox选中之后可以直接取消,RadioButton选中之后不能直接取消,所以一般情况下不建议单独使用.1.RadioGroup:RadioBu ...

  4. Android之RadioGroup+ViewPager制作的底部导航栏

    在日常开发中我们常常会用到类似微信或者QQ的底部导航.实现这样的效果有多种,今天就为大家介绍一种实现简单,可控性好的底部导航的实现方法. 首先创建activity_main.xml布局文件,里面主要由 ...

  5. android自定义RadioGroup实现可以添加多种布局

    android自带的RadioGroup是继承自LinearLayout,如果布局的时候不是直接写radiobutton,即radiobutton外面还包了一层容器,这时分组是不成功的,因为查找不到r ...

  6. Android中RadioGroup的初始化和简单的使用

    一简介: RadioGroup作为一个单选按钮组,可以设置为性别选择男或则女,地址选择等等,作为一个android入门级选手,就简单的说一下RadioGroup组中RadioButton的布局和初始化 ...

  7. android 自定义radiogroup的两种方式

    这里先备注下 listview+radiobutton实现  浅显易懂 http://www.haolizi.net/example/view_3312.html 在radiogoup原生态源码的基础 ...

  8. android checkbox radiogroup optionmenu dialog

    \n换行 UI visible:View.INVISIBLE 不可见,占用空间,View.GONE  不可见,不占用空间 菜单 res右击新建menu xml 自动新建menu文件夹 context ...

  9. Android RadioGroup和RadioButton详解

    实现RadioButton由两部分组成,也就是RadioButton和RadioGroup配合使用.RadioGroup是单选组合框,可以容纳多个RadioButton的容器.在没有RadioGrou ...

随机推荐

  1. jquery选择器之层级选择器

    HTML示例代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  2. ASP.NET SignalR 与 LayIM2.0 配合轻松实现Web聊天室(十三)之附加功能-自定义皮肤

    前言 本篇要讲的算是一个layim代码功能扩充.在原来的laim中已经有自带的换肤功能,而且在skin配置中,你可以添加自己想要的皮肤图片路径.这些内容在接下来都不会涉及,本篇要讲的是自定义皮肤功能, ...

  3. Ubuntu14.04搭建Caffe(仅CPU)

    一直以来都没有写博客的习惯,后来发现以前做的工作如果不注意及时整理和记录往往丢失的很快.对我而言这是一篇具有重要意义的文章,好的习惯要持之以恒,以后的日子我会常驻博客园!由于本人水平有限,智商略低,欢 ...

  4. WPF中嵌入普通Win32程序的方法

    公司现在在研发基于.Net中WPF技术的产品,由于要兼容旧有产品,比如一些旧有的Win32程序.第三方的Win32程序等等,还要实现自动登录这些外部Win32程序,因此必须能够将这些程序整合到我们的系 ...

  5. redis集群的一些笔记

    当节点数量少于6个时候会提示如下信息,初始化一个集群的时候需要6个节点,为什么?? *** ERROR: Invalid configuration for cluster creation. *** ...

  6. struts2 Demo

    参考资料 :http://www.cnblogs.com/yangy608/archive/2010/11/08/1871962.htmlhttp://www.yiibai.com/struts2/s ...

  7. 约瑟夫环(Josehpuse)的模拟

    约瑟夫环问题: 0,1,...,n-1这n个数字排成一个圆圈,从数字0开始每次从这个圆圈里删除第m个数字,求出这个圆圈里剩下的最后一个数字. 这里给出以下几种解法, 1.用队列模拟 每次将前m-1个元 ...

  8. mysql死锁问题分析

    线上某服务时不时报出如下异常(大约一天二十多次):“Deadlock found when trying to get lock;”. Oh, My God! 是死锁问题.尽管报错不多,对性能目前看来 ...

  9. discuz论坛与其它网站登录注册整合

    discuz论坛与其它网站登录注册整合 本文以discuz 7.0.0 php版本的论坛与 .net 2.0的网站注册登录整合为类.没有采用uc_center或第三方插件.以另类的方式实现.此方法实现 ...

  10. ubuntu Server 14 自动更新

    https://help.ubuntu.com/stable/serverguide/automatic-updates.html http://spin.atomicobject.com/2014/ ...