Android Shape

<?xml version="1.0" encoding="utf-8"?>
<!--
形状
    shape 所画的形状
-->
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <!--
    渐变 
        startColor 开始颜色 
        centerColor 中间颜色
        endColor 结束颜色
        angle 旋转角度
        gradientRadius 渐变半径
        centerX 取值float(0~1) (以控件自身的比例计算)
        centerY 取值float(0~1)
        useLevel ??
        (PS:默认从左到右 与 angle角度有关)
    -->
    <gradient
        android:startColor="#ffff0000" 
        android:centerColor="#ff00ff00"
        android:endColor="#ff0000ff"
        android:centerX="0.5"
        android:centerY="0.5"
        />
    <!-- 
    填充 
        (PS:单色与 gradient属性 二选一)
    -->
    <solid 
        android:color="#ff00ffff"
        />
    <!-- 
    边框
        color 颜色
        width 宽度
        dashGap 间隙
        dashWidth dashGap设置后->每一个边框的显示宽度
     -->
    <stroke
        android:color="#ff0f0f00"
        android:width="5dp"
        />
    <!-- 
    圆角
        radius 默认四个角
        topLeftRadius 上左
        topRightRadius 上右
        bottomLeftRadius 下左
        bottomRightRadius 下右
    -->
    <corners
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp"
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        />
    <!-- 
    间距
        与内容的间距
    -->
    <padding
        android:left="20dp"
        android:top="20dp" 
        android:right="20dp"
        android:bottom="20dp"
        />
    <!--
    大小
    -->
    <size 
        android:width="200dp"
        android:height="200dp"
        />
</shape>

PS:这是我对shape的一些理解

原文地址:https://www.cnblogs.com/smile365/p/3180644.html