【Android开发】自定义圆角button样式
结果图
步骤
在res/drawable中新建一个drawable文件,自定义命名为btu.xml;在btu.xml中设置圆角大小和填充颜色,代码如下:<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="/apk/res/android"><!--圆角的半径--><corners android:radius="5dp"/><!-- 填充颜色--><solid android:color="@color/colorAccent"/></shape>
在需要按钮的布局文件中新建一个button,设置其他属性,在background中选择btu,代码如下:
<Buttonandroid:id="@+id/edit_commit"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:layout_marginTop="10dp"android:background="@drawable/btu_normal"android:text="点击提交" />