首先创建两个按下和弹起的button圆角资源文件
//circle_btn_normal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 设置圆角 -->
<corners android:radius="6dp" >
</corners>
<!-- 设置填充色 -->
<solid android:color="@color/ActionBar" >
</solid>
<padding android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp" />
<!-- 设置边框的颜色和宽度 -->
<stroke
android:width="1dp"
android:color="@color/ActionBar" >
</stroke>
</shape>
//circle_btn_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- shape如果不声明形状默认是正方形 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 设置圆角 -->
<corners android:radius="6dp" >
</corners>
<!-- 设置填充色 -->
<solid android:color="@color/gray" >
</solid>
<padding android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp" />
<!-- 设置边框的颜色和宽度 -->
<stroke
android:width="1dp"
android:color="@color/gray" >
</stroke>
</shape>
然后创建一个selector_bg_btn.xml来引用这两个资源
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/circle_btn_normal" android:state_pressed="false"/> <item android:drawable="@drawable/circle_btn_pressed" android:state_pressed="true"/></selector>
最后在button的background属性里面引用这个selector_bg_btn.xml
android:background="@drawable/selector_bg_btn"