圆角Button

第一步

演示一个登陆按钮,在drawable下新建radius_button_login.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <!--设置渐变色-->
    <gradient android:startColor="#6fda9c" android:endColor="#56c5ee"/>
    <!--设置圆角-->
    <corners
        android:bottomLeftRadius="20dp"
        android:bottomRightRadius="20dp"
        android:topLeftRadius="20dp"
        android:topRightRadius="20dp" />
</shape>

如果不需要渐变色可以用这个格式代替背景色

<solid android:color="#FFF"/>

第二步

在布局文件进行引用

android:background="@drawable/radius_button_login"

登陆按钮的整体如下

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="60dp"
            android:layout_marginRight="60dp"
            android:layout_marginTop="16dp"
            android:background="@drawable/radius_button_login"
            android:minHeight="0dp"
            android:minWidth="0dp"
            android:paddingBottom="8dp"
            android:paddingTop="8dp"
            android:text="登陆"
            android:textColor="#FFF"
            android:textSize="18dp" />

效果图

最后一个登陆按钮就是效果图,前面两个白色按钮实现过程是一样的,就不再赘述了。
这里写图片描述

猜你喜欢

转载自blog.csdn.net/weixin_37418246/article/details/82528127