android之RadioGroup
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的更多相关文章
- Android自定义控件----RadioGroup实现APP首页底部Tab的切换
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...
- android学习--radiogroup学习
这个阶段在学习android的相关基本UI现将相关练习的代码粘贴在此便于后期学习之用(radio控件) 效果图: main_layout.xml <?xml version="1. ...
- Android 使用RadioGroup和RadioButton实现单选效果
RadioButton和CheckBox的区别:CheckBox选中之后可以直接取消,RadioButton选中之后不能直接取消,所以一般情况下不建议单独使用.1.RadioGroup:RadioBu ...
- Android之RadioGroup+ViewPager制作的底部导航栏
在日常开发中我们常常会用到类似微信或者QQ的底部导航.实现这样的效果有多种,今天就为大家介绍一种实现简单,可控性好的底部导航的实现方法. 首先创建activity_main.xml布局文件,里面主要由 ...
- android自定义RadioGroup实现可以添加多种布局
android自带的RadioGroup是继承自LinearLayout,如果布局的时候不是直接写radiobutton,即radiobutton外面还包了一层容器,这时分组是不成功的,因为查找不到r ...
- Android中RadioGroup的初始化和简单的使用
一简介: RadioGroup作为一个单选按钮组,可以设置为性别选择男或则女,地址选择等等,作为一个android入门级选手,就简单的说一下RadioGroup组中RadioButton的布局和初始化 ...
- android 自定义radiogroup的两种方式
这里先备注下 listview+radiobutton实现 浅显易懂 http://www.haolizi.net/example/view_3312.html 在radiogoup原生态源码的基础 ...
- android checkbox radiogroup optionmenu dialog
\n换行 UI visible:View.INVISIBLE 不可见,占用空间,View.GONE 不可见,不占用空间 菜单 res右击新建menu xml 自动新建menu文件夹 context ...
- Android RadioGroup和RadioButton详解
实现RadioButton由两部分组成,也就是RadioButton和RadioGroup配合使用.RadioGroup是单选组合框,可以容纳多个RadioButton的容器.在没有RadioGrou ...
随机推荐
- java bean 转换工具
考量要素: 1.简单的约定优于配置的同名属性copy 2.嵌套属性copy 3.flattern(扁平化)支持,要支持N层结构的copy到一层结构. 4.性能 如下这个网页,里面提到了好多工具. ht ...
- SocketTcpClient
public class SocketTcpClient { public static string ErrorMsg = string.Empty; private static Socket _ ...
- 并查集——HDOJ-1232-畅通工程
并查集 并查集(Union-Find Sets)是一种非常精巧而实用的数据结构,它主要用于处理一些不相交集合的合并问题,在合并之前,需要先判断两个元素是否属于同一集合,这就需要用查找操作来实现.一些常 ...
- javascript性能优化总结一(转载人家)
一直在学习javascript,也有看过<犀利开发Jquery内核详解与实践>,对这本书的评价只有两个字犀利,可能是对javascript理解的还不够透彻异或是自己太笨,更多的是自己不擅于 ...
- 导入Eclipse工程 到 Android Studio
一.从Eclipse导入工程到Android Studio 根据官方的介绍,Android Studio可以兼容Eclipse的现有工程,但需要做一些操作: 首先升级ADT到最新版本,目前为版本号为2 ...
- (整理)PowerDesign与EF的文档说明
最近通过PowerDesign->SQLServer->VS的方式,将数据库设计.创建.实体模型生成等环节打通,发现VS中的Model竟然没有说明,然后就在园子里找了一下,发现了园友的文章 ...
- NandFlash读写
1.NandFlash分类 根据物理结构上的区别,NandFlash主要分为如下两类:•SLC (Single Level Cell): 单层式存储•MLC (Multi Level Cell): 多 ...
- lisp 题目
1.根据二叉树的中序,前序生成生成二叉树的后续 2.BFPRT算法
- Linux命令总结:file
转自:http://www.cnblogs.com/kerrycode/p/3806618.html 1.命令简介:用来识别文件类型,也可辨别一些文件的编码格式.它是通过查看文件的头部信息来获取文件类 ...
- 转:RTC搭建android下三层应用程序访问服务器MsSql-客户端
原文:http://www.cnblogs.com/delphi007/p/3346084.html android下stringgrid已知问题: 通过点击时获取对应行的值有问题,在win下调试正常 ...