1.shape的基本使用

根据官方给出的API整理的:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape=["rectangle"//矩形 | "oval"//椭圆 | "line"//线 | "ring"//圆环] >

    <corners//圆角
        android:radius="integer"
        android:topLeftRadius="integer"
        android:topRightRadius="integer"
        android:bottomLeftRadius="integer"
        android:bottomRightRadius="integer" />

    <gradient//渐变
        android:angle="integer"//渐变角度0:左到右;90:下到上;180:右到左;270:上到下
        android:centerX="integer"//表示渐变的X轴起始位置,范围0-1,0.5表示圆心。
        android:centerY="integer"
        android:centerColor="integer"
        android:endColor="color"
        android:gradientRadius="integer"
        android:startColor="color"
        android:type=["linear"//线性渐变 | "radial"//放射渐变 | "sweep"//扫描性渐变]//渐变类型
        android:useLevel=["true" | "false"]//一般为flase/>

    <padding//内边距
        android:left="integer"
        android:top="integer"
        android:right="integer"
        android:bottom="integer" />

    <size
        android:width="integer"
        android:height="integer" />

    <solid//填充色
        android:color="color" />

    <stroke//边框
        android:width="integer"
        android:color="color"
        android:dashWidth="integer"//虚线间距宽度
        android:dashGap="integer"//虚线宽度 />
</shape>