Android中使用shape
- corners–圆角
- padding–内边距
- size(height、width)–设置宽高
- stroke–描边
- gradient–渐变
- solid–填充
分别
1.corners–圆角
<corners android:radius="10dp" android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp"> </corners>
设置radius=”10dp”等同于:上下左右分别设置为10dp,反之同理
2.padding–内边距
<padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp"/>
3.size(height、width)–设置宽高
<size android:height="10dp" /> <size android:width="100dp"/>
4.stroke–描边
<stroke android:color="@color/red_200" android:width="2dp" android:dashWidth="1dp" android:dashGap="1dp">
</stroke>
width:描边的宽度;color:描边的暗色;dashGap:默认0dp为实线,不为0时为虚线,值代表虚点之间的距离;dashWidth:为虚线时,控制虚点的宽度
5.gradient–渐变
<gradient android:centerColor="#ff00ff00" android:endColor="#ff0000ff" android:startColor="#ffff0000" android:gradientRadius="100dp" android:type="radial" />
startColor设置起始颜色,endColor结束颜色,centerColor中间色
当type为radial表示为以gradientRadius半径为中心向周围渐变
当type为linear时gradientRadius无效
6.solid–填充
<solid android:color="@android:color/white"></solid>

浙公网安备 33010602011771号