您的位置:首页 > 产品设计 > UI/UE

Android中在xml中使用shape美化UI

2016-04-22 16:37 696 查看
shape:定义控件的几何形状,如定义一个圆角的Button,设置渐变色等;当使用shape时,在res/drawable下新建.xml文件选择shape;

一.shape中的属性:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval":椭圆形状
shape="line":线型
shape="rectangle":矩形
shape="ring">

二.shape中子元素的属性:

1.设置渐变色:gradient

<gradient
android:startColor="#030303":设置开始颜色
android:type="radial":设置渐变放式为放射式
type="linear":平行式渐变
type="sweep":扫描渐变
android:endColor="#fff000":设置终止颜色
android:gradientRadius="200%p":设置渐变半径,该属性只有当type="radial"时有效
android:centerColor="#2E8B57"/>:设置中间颜色

2.设置圆角:corners
<corners android:radius="20dp":设置圆角的全部半径
android:topLeftRadius="40dp"设置左上角半径,类推。。。
android:topRightRadius="10dp"
android:bottomLeftRadius="50dp"
android:bottomRightRadius="20dp"/>3.设置内间距:padding
<padding android:top="20dp"
android:left="20dp"
android:right="20dp"
android:bottom="20dp"/>4.设置大小:size
<size android:width="100dp"
android:height="100dp"/>


5.设置一致颜色:solid
<solid android:color="#ff00ff"/>:设置该属性后,不会再有渐变效果6.进行描边:stroke
<stroke android:width="10dp":描笔的高度(不是宽度)
android:color="#ff00ff":描笔的颜色
android:dashWidth="20dp":描笔的宽度
android:dashGap="10dp"/>:相邻描笔之间的间隔
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UI美化 shape android