操作过程
1. 在drawable中新建一个button_circle_shape.xml
但是建立这个xml是有操作的,因为从drawable右键是创建不了xml的, 具体操作如下:
右键res–>New–>Android resourse file
注意Root element 是不能选择的 是直接填写为shape, 默认应该是selector 把它改为shape即可
然后就可以看见在drawable 成功添加了xml
2.填写代码
button_circle_shape.xml 内容如下
这个xml里有一个shape,此shape规定了圆角按钮的样式
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
android:radius="5dip" />
**设置文字padding**
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"
/>
3.使用shape:
给button的background属性赋值为刚创建的
android:background="@drawable/button_circle_shape"