1、在drawable文件夹下新建button_shape.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android = "http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--设置背景色-->
<solid android:color="#20a4e5"/>
<!--设置圆角-->
<corners android:radius="10dip"/>
<!--设置边框线的宽度和颜色-->
<stroke android:width="2dp" android:color="#fffff" />
</shape>
2、将Button 的background属性设置为:android:background="@drawable/button_shape"
<Button
android:id="@+id/loginBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_shape"
android:text="登录"/>
注:本文为学习笔记,供给像我这样的小白学习