先上效果图

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. Hexo-使用

    hexo 写新文章 创建新的文章 ``` bash $ hexo new "Hexo-使用" ``` 生成md文件 ``` bash $ hexo generate ``` 写文章 ...

  2. sql查询练习

    #建学生信息表student create table student ( sno varchar(20) not null primary key, sname varchar(20) not nu ...

  3. man 命令帮助文件输出乱码

    man 命令重定向的时候有写控制字符再直接显示的时候没有问题, 但是重定向到文件中的时候,被解释错误,显示为 ^H 或者乱码 解决方法: man ps | col -b >a.txt 可以消除所 ...

  4. Spring Boot 常见标签

    @Controller(value=“名字”,descripation="描述",tags="具体" ) @RestController控制器(path=&qu ...

  5. vs2015和Oracle在一起时的Shit问题

    VS2015在连接Oracle时,必须要安装到一个不含有空格的目录中去,否则连接不上Oracle,至于为什么,不知道,鬼知道,日的. 如果你不幸以前安装过VS2015,安装到它的默认的什么“progr ...

  6. ASP.NET MVC 阻止通过Url直接访问服务器上的静态文件

    某些情况下我们需要在服务器上保存一些静态文件,比如用户上传到服务器的文件,如果刚好这些文件的保存目录是应用程序目录下的一个子目录的话,别人就可以通过Url直接访问这个文件. 例如:在应用程序目录下的U ...

  7. HttpConnection详解【转】

    HttpConnection详解[转]   HttpURLConnection对象  1.从Internet获取网页,发送请求,将网页以流的形式读回来. 步骤:1)创建一个URL对象:URL url ...

  8. 在Power BI报表和仪表板中显示刷新日期\时间

    有人最近问我:“如何在报告和仪表板中显示最后刷新数据的日期和时间?”这里有两个简单的技巧在这分享下,也许可以帮助到你. 显示上次刷新日期\时间 要想显示刷新的日期和时间,我们需要在模型本身中存储时间刷 ...

  9. Mysql 杀死sleep进程

    查询数据库当前设置的最大连接数:查看mysql数据库连接数.并发数相关信息  show global variables like '%max_connections%'; 查看mysql连接数:my ...

  10. Tomcat下载和安装

    一.Tomcat下载和安装 Tomcat 是一个免费的开放源代码的 Servlet 容器,它是 Apache 软件基金会的一个顶级项目,由 Apache,Sun和其他一些公司及个人共同开发而成.由于有 ...