一个android的按钮

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true"><shape>

            <!-- 描边 -->
            <stroke android:width="1dp" android:color="@android:color/transparent" />
            <!-- 圆角 -->
            <corners android:radius="5dp" />
            <!-- 填充 -->
            <solid android:color="#56F391" />
        </shape></item>
    <item android:state_checked="true"><shape>

            <!-- 描边 -->
            <stroke android:width="1dp" android:color="@android:color/transparent" />
            <!-- 圆角 -->
            <corners android:radius="5dp" />
            <!-- 填充 -->
            <solid android:color="#56F391" />
        </shape></item>
        <item android:state_focused="true"><shape>

            <!-- 描边 -->
            <stroke android:width="1dp" android:color="@android:color/transparent" />
            <!-- 圆角 -->
            <corners android:radius="5dp" />
            <!-- 填充 -->
            <solid android:color="#56F391" />
        </shape></item>
    <item><shape>
            <!-- 圆角 -->
            <corners android:radius="5dp" />
            <!-- 填充 -->
            <solid android:color="#4BB26D" />
        </shape></item>

</selector>

//颜色渐变的一条直线
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#FFeeeeee"
            android:centerColor="#FF111111"
            android:endColor="#FFeeeeee"/>
</shape>

相关推荐