1.res文件夹下创建drawable文件
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#ff621d"></solid> //填充颜色 <stroke android:width="1dp" android:color="#D5D5D5"></stroke>//边框线的宽度,颜色 <corners android:radius="0dp" />//矩形的圆角半径 </shape>
2.通过更改圆角度数、边框线颜色、填充颜色可以将形状调整为矩形、空心矩形、圆角矩形、圆形、空心圆等
3.编辑完成后在布局文件中通过控件的属性@drawable/xml文件名称进行调用