100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 【Android开发】自定义圆角button样式

【Android开发】自定义圆角button样式

时间:2018-11-04 14:31:06

相关推荐

【Android开发】自定义圆角button样式

【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="点击提交" />

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。