shape 图形

前端之家收集整理的这篇文章主要介绍了shape 图形前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

主要属性

<?xml version="1.0"encoding="utf-8"?>
<shape >
<corners />
<gradient />
<padding />
<size />
<solid />
<stroke />
</shape>

1、corners属性(圆角):

<corners
android:radius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="20dp"
android:bottomRightRadius="30dp"
android:bottomLeftRadius="40dp"/>

2、gradient属性(渐变色):

<gradient
android:type="radial"
android:angle="0"
android:startColor="@color/red"
android:centerColor="@color/green"
android:endColor="@color/white"
android:centerX="0.3"
android:centerY="0.5"
android:useLevel="false"
android:gradientRadius="200dp"/>

type:取值["linear" | "radial" | "sweep"]共有3中渐变类型,分别是线性渐变(默认)、放射渐变、扫描式渐变。

angle:仅对线性渐变有效,0为从左到右(逆时针旋转),必须为45的倍数,90为从下到上。

3、padding属性

<padding

android:bottom="2dp"

android:left="3dp" 

android:right="3dp" 

android:top="2dp"/>

4、size属性

<size

android:width="180dp"

android:height="100dp"/>

5、solid属性

 <solid android:color="#ff5900"/>

6、stroke属性(描边):

<stroke

android:width="5dp" 

android:color="@color/red"

android:dashWidth="100dp"

android:dashGap="50dp"/>

7、shape属性

<?xml version="1.0"encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:dither="false" android:tint="@color/red" android:tintMode="src_atop" android:visible="true" android:innerRadius="100dp" android:innerRadiusRatio="20" android:thickness="100dp" android:thicknessRatio="6" android:useLevel="false"></shape>

猜你在找的XML相关文章