效果图:
首先我们写button的样式:在 drawable目录 下新建 button_bg_style.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<!--填充色-->
<solid android:color="@android:color/transparent"/>
<!--边框的宽 和 边框颜色-->
<stroke android:width="0.5px" android:color="@android:color/holo_red_dark"/>
<!--按钮的四个角为 弧角 -->
<!-- 弧角radius 半径-->
<corners android:radius="10dp"/>
</shape>
然后在使用button的时候,将样式加到background上:
就能达到上面效果啦!