创建:在res/drawable下创建:sha_btn.xml
使用:在XML中
android:background="@drawable/sha_btn"
配合selector使用:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/sha_btn" android:state_activated="false" />
<item android:drawable="@drawable/sha_btn" android:state_activated="true" />
</selector>
shape可以自定义形状,通过android:shape指定以下四种形状:
1.rectangle: 矩形,默认的形状,可以画出直角矩形、圆角矩形、弧形等
2.oval: 椭圆形,用得比较多的是画正圆
3.line: 线形,可以画实线和虚线
4.ring: 环形,可以画环形进度条
在shape根属性中包含有以下属性:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="false|true" //将在位图的像素配置与屏幕不同时(例如:ARGB 8888 位图和 RGB 565 屏幕)启用位图的抖动;值为“false”时则停用抖动。默认值为 true。
android:shape="rectangle|