先上效果图

message_toolbar_left_bg_selector

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="10.0dp" android:bottomRightRadius="0.0dp" android:topLeftRadius="10.0dp" android:topRightRadius="0.0dp" />
<solid android:color="@color/orange" />
</shape>
</item>
<item android:state_pressed="true">
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="10.0dp" android:bottomRightRadius="0.0dp" android:topLeftRadius="10.0dp" android:topRightRadius="0.0dp" />
<solid android:color="@color/orange" />
</shape>
</item>
<item android:state_checked="true">
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="10.0dp" android:bottomRightRadius="0.0dp" android:topLeftRadius="10.0dp" android:topRightRadius="0.0dp" />
<solid android:color="@color/orange" />
</shape>
</item>
<item>
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="10.0dp" android:bottomRightRadius="0.0dp" android:topLeftRadius="10.0dp" android:topRightRadius="0.0dp" /> <solid android:color="@color/white"/></shape>
</item>
</selector>

  

message_toolbar_right_bg_selector

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="0.0dp" android:bottomRightRadius="10.0dp" android:topLeftRadius="0.0dp" android:topRightRadius="10.0dp" />
<solid android:color="@color/orange" />
</shape>
</item>
<item android:state_pressed="true">
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="0.0dp" android:bottomRightRadius="10.0dp" android:topLeftRadius="0.0dp" android:topRightRadius="10.0dp" />
<solid android:color="@color/orange" />
</shape>
</item>
<item android:state_checked="true">
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="0.0dp" android:bottomRightRadius="10.0dp" android:topLeftRadius="0.0dp" android:topRightRadius="10.0dp" />
<solid android:color="@color/orange" />
</shape>
</item>
<item>
<shape>
<size android:width="69.0dp" android:height="27dp" />
<!-- 线的宽度,颜色灰色 -->
<stroke android:width="0.5dp" android:color="@color/orange"></stroke>
<!-- 矩形的圆角半径 -->
<corners android:bottomLeftRadius="0.0dp" android:bottomRightRadius="10.0dp" android:topLeftRadius="0.0dp" android:topRightRadius="10.0dp" /> <solid android:color="@color/white" />
</shape>
</item>
</selector>

  布局界面

 <RadioGroup
android:id="@id/rg_group"
android:layout_width="138.0dp"
android:layout_height="27.0dp"
android:layout_centerInParent="true"
android:orientation="horizontal"> <RadioButton
android:id="@id/rbtn_message"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:checked="true"
android:gravity="center"
android:background="@drawable/message_toolbar_left_bg_selector"
android:text="标题1"
android:textColor="@color/message_toolbar_font_color" /> <RadioButton
android:id="@id/rbtn_chat_room"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:background="@drawable/message_toolbar_right_bg_selector"
android:text="标题2"
android:textColor="@color/message_toolbar_font_color" />
</RadioGroup>

  

android selector shape 使用的更多相关文章

  1. android selector 开始自定义样式

    Selector的结构描述: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:a ...

  2. android selector(转)

    Selector的结构描述: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:a ...

  3. Android UI设计系统-android selector 开始自定义样式

    Selector的结构描述: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:a ...

  4. Android 使用shape定义不同控件的的颜色、背景色、边框色

    Android 使用shape定义不同控件的的颜色.背景色.边框色 设置按钮的右边框和底边框颜色为红色,边框大小为3dp: 在drawable新建一个 buttonstyle.xml的文件,内容如下: ...

  5. Android学好Shape不再依赖美工

    原创 2014年03月27日 15:33:41 标签: Android Shape用法 20427 先上图 其实以上效果没有让美工提供任何图片 只要学会Shape你就能实现 想怎么样就怎么样 下面介绍 ...

  6. 【转】【Android】Android Drawable Shape 组合画田字格

    使用layer-list组合多个Shap <?xml version="1.0" encoding="utf-8"?> <layer-list ...

  7. selector + shape

    selector_shape.xml<?xml version="1.0" encoding="utf-8"?> <selector xmln ...

  8. android中shape 的使用

    android 开发中 对于 shape 和 selector的使用,一直都不是很熟练, 记录一下.便于以后参考. 举个项目中例子图 对于上面的2个radiobutton ,背景我们可以让美工做一个. ...

  9. Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)

    Android XML shape 标签使用详解   一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...

随机推荐

  1. @ControllerAdvice + @ExceptionHandler 全局处理 Controller 层异常

    @ControllerAdvice 和 @ExceptionHandler 的区别 ExceptionHandler, 方法注解, 作用于 Controller 级别. ExceptionHandle ...

  2. intellij idea 编译 kafka 源码

    1. 从 GitHub 网站,git clone kafka 源码 2. 下载安装好 gradle,scala 3. 进入 kafka 项目目录,依次执行 gradle wrapper,gradle ...

  3. 微服务架构演变过程-SpringCloud

  4. Android7.0手机程序保活(附源码下载)

    项目地址,求starhttps://github.com/979451341/AppAlive 本人在学习音视频时无意发现的黑科技,发现在使用AudioTrack播放音乐时,使用手机的一键清理发现程序 ...

  5. 读取磁盘:CHS方式

    读取磁盘:CHS方式 BIOS读取磁盘 读取磁盘也是调用BIOS: 中断命令: INT 13H 读取扇区的入口参数为 AH = 02H 功能参数,读取扇区 AL = 扇区数 CH = 柱面 CL = ...

  6. Linux磁盘挂载

            mount命令 用于加载文件系统到指定的加载点.此命令的最常用于挂载cdrom,使我们可以访问cdrom中的数据,因为你将光盘插入cdrom中,Linux并不会自动挂载,必须使用Lin ...

  7. PAT B1029

    # PAT B1029 这道题主要有两个问题需要解决: 如何在不区分大小写的情况下判断第一个字符串中有哪些字符串没有在第二个中出现 如何确保同一个字符(不区分大小写)只输出一次,且英文均用大小写输出 ...

  8. Locust 参数化

    概述: 和Loadrunner一样对于多用户并发时,重复登入或者数据的重复使用会造成脚本的失败,那么我们引入Loadrunner的参数化概念,对用户数据进行参数化来使脚本运行成功. 头绪:   use ...

  9. C#如何运行外部程序(打开可执行程序):ShellExcute和Process

    最近的任务用到C#来调用C++内核程序,也就是C++编译运行后生成的.exe文件.网搜了一下C#中运行外部程序大致有两种方法,在此稍作总结: (1)使用API函数ShellExcute 添加引用 us ...

  10. Ubuntu下math库函数编译时未定义问题的解决

    自己在Ubuntu下练习C程序时,用到了库函数math.h,虽然在源程序中已添加头文件“math.h”,但仍提示所用函数未定义,原本以为是程序出错了,找了好久,这是怎么回事呢? 后来上网查了下,发现是 ...