新建一个xml,名称自定,放在drawable中,代码如下:
<!--custom_button.xml-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF0000"/> <!--设置按钮填充颜色-->
<corners android:radius="5dp"/> <!--设置按钮圆角半径-->
<stroke
android:width="2dp" <!--设置按钮边框宽度-->
android:color="#000000" <!--设置按钮边框颜色-->
android:dashWidth="10dp" <!--设置按钮边框虚线宽度-->
android:dashGap="5dp" <!--设置按钮边框虚线间隔-->
/>
<padding
android:left="10dp" <!--设置按钮内容左边距-->
android:top="5dp" <!--设置按钮内容上边距-->
android:right="10dp" <!--设置按钮内容右边距-->
android:bottom="5dp" <!--设置按钮内容下边距-->
/>
</shape>