1.新建一个radius_border.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" /><!--solid 背景填充颜色 -->
<stroke android:width="1dip" android:color="#aea594" /><!-- 描边,边框宽度、颜色 -->
<corners android:topLeftRadius="10dp"
android:topRightRadius="10dp"
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
/><!-- 边角圆弧的半径 -->
<padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp" /><!-- 四周留出来的空白 --> </shape>

在项目中我们可能边框只需要加一边的办法

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="#ffffff"/>
<stroke
android:width="1dp"
android:color="#ff0000"/>
</shape>
</item>
</layer-list>

2.在代码中添加一句:

TextView.setBackgroundResource(R.drawable.radius_border);

这里可能回报一句错误element shape doesn't required attribute android:layout_height

解决方法:

radius_border.xml移动到drawable中即可

3.button根据焦点改变北京图片

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" > <!--android:drawable="@drawable/ic_launcher"-->
<item android:state_pressed="true" > <shape> <solid android:color="#ff1234" ></solid>
<corners android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
/> </shape> </item> <!--android:state_focused是获得焦点android:state_pressed是点击--> <item android:state_focused="true"
android:drawable="@drawable/ic_launcher" > <shape> <solid android:color="#ffaeff5d"></solid>
<corners android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
/> </shape> </item>
<item>
<shape> <solid android:color="@color/colorNav"></solid>
<corners android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
/> </shape>
</item> </selector>

android 控件加圆角的更多相关文章

  1. 50个Android开发技巧(12 为控件加入圆角边框)

    控件的圆角边框能够使你的App看起来更美观,事实上实现起来也非常easy. (原文地址:http://blog.csdn.net/vector_yi/article/details/24463025) ...

  2. iOS 在xib或storyboard里为控件添加圆角、外框和外框颜色

    如果要在xib和storyboard里为控件添加圆角和外框宽度,只要这样做就可以 layer.borderWidth     设置外框宽度属性 layer.cornerRadius    设置圆角属性 ...

  3. android控件的属性

    android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...

  4. iOS在xib或storyboard里为控件添加圆角、外框和外框颜色

    如果要在xib和storyboard里为控件添加圆角和外框宽度,只要这样做就可以: layer.borderWidth 设置外框宽度属性 layer.cornerRadius 设置圆角属性 只要为属性 ...

  5. Android群英传笔记——第三章:Android控件架构与自定义控件讲解

    Android群英传笔记--第三章:Android控件架构与自定义控件讲解 真的很久没有更新博客了,三四天了吧,搬家干嘛的,心累,事件又很紧,抽时间把第三章大致的看完了,当然,我还是有一点View的基 ...

  6. 一步一步学android控件(之六) —— MultiAutoCompleteTextView

    今天学习的控件是MultiAutoCompleteTextView . 提到MultiAutoCompleteTextView 我们就自然而然地想到AutoCompleteTextView ,就想知道 ...

  7. Android控件介绍

    1. 介绍 Android控件大多位于android.widget, android.view.View为他们的父类对于Dialog系列, android.app.Dialog为父类 Android的 ...

  8. Android控件常见属性

    1.宽/高android:layout_width android:layout_height// 取值match_parent //匹配父控件wrap_content //自适应,根据内容 如果指定 ...

  9. Android控件RecyclerView的基本用法

    Android控件RecyclerView的基本用法 转 https://www.jianshu.com/p/e71a4b73098f   github: https://github.com/Cym ...

随机推荐

  1. hbase集群部分节点HRegionServer启动后自动关闭的问题

    参考链接 http://f.dataguru.cn/thread-209058-1-1.html 我有4HRegionServer节点,1个master,其中3个是unbuntu 系统,2个节点是ce ...

  2. SQL Server 查询数据库表的列数

    select count(*) from sysobjects a join syscolumns b on a.id=b.id where a.name='表名' go

  3. 在MathType如何让括号随内容自动调整大小的技巧

    MathType软件是一款数学公式编辑器工具可以轻松输入各种复杂的公式和符号,与Office文档完美结合,显示效果超好,比Office自带的公式编辑器要强大很多.但是很多的新手朋友不知道在MathTy ...

  4. Notepad++下载需要的插件(如何在Notepad++中手动下载需要的插件)

    需求说明: 下载在实际工作中需要的Notepad++插件,或者是因为Notepadd++设置的原因导致不能直接在软件中显示插件. 即手动登录到指定的链接中进行插件的下载. 操作过程: 1.以xmlto ...

  5. zookeeper 系列文章

    http://blog.csdn.net/tswisdom/article/details/41522069 http://blog.csdn.net/tswisdom/article/details ...

  6. Java精选笔记_JSP技术

    JSP技术 JSP概述 什么是JSP 在JSP全名是Java Server Page,它是建立在Servlet规范之上的动态网页开发技术. 在JSP文件中,HTML代码与Java代码共同存在,其中,H ...

  7. Java精选笔记_IO流(字节流、InputStream、OutputStream、字节文件、缓冲区输入输出流)

    字节流 操作图片数据就要用到字节流. 字符流使用的是字符数组char[],字节流使用的是字节数组byte[]. 字节流读写文件 针对文件的读写,JDK专门提供了两个类,分别是FileInputStre ...

  8. Android中Parcelable和Serializable接口用法

    1. Parcelable接口 Interface for classes whose instances can be written to and restored from a Parcel. ...

  9. 首个vue.js项目收尾中……

    前言: 4.26号入手vue.js+elementUI,迄今为止我们的工作应该可以暂时告一段落了:下周开始,又是新的“征程”. 过程:站在接近完成的角度来看这个项目,似乎的确有许多事情需要自己阐述. ...

  10. shiro-filter执行流程

    web中 在xml中配置 <filter> <filter-name>shiroFilter</filter-name> <filter-class>o ...