Android中定义圆角,加边框、按下状态的drawable

// 放在drawable目录即可
<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false">
        <shape>
            <solid android:color="#color1" />
            <corners android:radius="5dp" />
            <stroke android:width="1dp" android:color="#border_color" />
        </shape>
    </item>
    <item android:state_pressed="true">
        <shape>
            <solid android:color="#color2" />
            <corners android:radius="5dp" />
            <stroke android:width="1dp" android:color="#border_color" />
        </shape>
    </item>
    <item>
        <shape>
            <solid android:color="#color3" />
            <corners android:radius="5dp" />
            <stroke android:width="1dp" android:color="#border_color" />
        </shape>
    </item>
</selector>

如上,solid是背景色、corners是圆角、stroke是边框

Leave a Reply

Your email address will not be published. Required fields are marked *