您的位置:首页 > 移动开发 > Android开发

android里shape与渐变色学习

2016-04-26 15:22 513 查看
先说下shape

资源文件里主要包括:边角(corners),渐变色(gradrent),大小(size),边距(padding) ,填充(solid),扫边(stoke)

先说下边角

[html] view
plain copy







<corners

android:radius=""

android:topLeftRadius=""

android:topRightRadius=""

android:bottomLeftRadius=""

android:bottomRightRadius="" />

每个值都是整数dp,设置的是边角半径

渐变色

[html] view
plain copy







<gradient

android:angle=""

android:centerColor=""

android:endColor=""

android:startColor=""

/>

第一个表示的是渐变渐变方向,必须是45的整数倍

大小

[html] view
plain copy







<size

android:width=""

android:height="" />

边距

[html] view
plain copy







<padding

android:left=""

android:top=""

android:right=""

android:bottom="" />

填充

[html] view
plain copy







<solid

android:color="color" />

扫边

[html] view
plain copy







<stroke

android:width=""

android:color="color"

android:dashWidth=""

android:dashGap="" />

上面两个表示实线,width表示表示实线宽度,dashwidth表示虚线宽度,dashGap表示之间的间距

对了shape还有

Android:shape=["rectangle" | "oval" | "line" | "ring"]

rectangle表示矩形

shape是用来定义形状的,gradient定义该形状里面为渐变色填充,startColor起始颜色,endColor结束颜色,angle表示方向角度。当angle=0时,渐变色是从左向右。 然后逆时针方向转,当angle=90时为从下往上。

android:shape 配置的是图形的形式,主要包括方形、圆形等,上边代码为方形。gradient节点主要配置起点颜色、终点颜色、中间点的坐标、中间点的颜色、渐变角度(90度为上下渐变,0为左右渐变),padding节点主要配置上下左右边距,corners节点配置四周园角的半径

LinearGradient : 线性渐变

RadialGradient : 环形渐变

SweepGradient : 扫描渐变---围绕一个中心点扫描渐变就像电影里那种雷达扫描

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: