一:使用简介
shape.xml中是用来让某控件、布局边角呈现弧形的一种方式。其原理就是某控件、布局设置其背景参数为shape.xml
二:使用
1:在drawble目录下新建一布局文件
在drawble目录下(最好用文件浏览器打开drawble而不是drawble-24)新建一布局文件,其根元素设置为“shape
”;
2:参数
solid
控制其背景颜色
<solid
android:color="#EBE8E8"/>
corner
控制其弧度半径
<corners
android:topLeftRadius="7dp"
android:topRightRadius="7dp"
android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"/>
stroke
控制其边缘宽度、颜色
<stroke
android:width="1dp"
android:color="#1893C9" />
示例文件
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="#EBE8E8"/>
<corners
android:topLeftRadius="7dp"
android:topRightRadius="7dp"
android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"/>
<stroke
android:width="1dp"
android:color="#1893C9" />
</shape>
3:应用
XML引用:
设置android:background=""
来应用;
Java应用:
使用setBackground()来应用。