设置Button按钮上面圆角下面直角

来源:互联网 发布:mysql获取union条数 编辑:程序博客网 时间:2024/05/01 14:32

<?xml version="1.0"encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape>
        <solid
            android:color="#151104"
/>
        <corners
        android:bottomLeftRadius="0dip"
        android:bottomRightRadius="0dip"
        android:topLeftRadius="5dip"
        android:topRightRadius="5dip"
/>
    </shape>
</item>
    <item
        android:bottom="1dp"
        android:right="1dp"
        android:top="1dp"
        android:left="1dp"
>
        <shape>
            <gradient
                android:startColor="#eb6b00"
                android:centerColor="#ef8000"
                android:endColor="#f49500"
                android:type="linear"
                android:angle="90"
                android:centerX="0.5"
                android:centerY="0.5"
/>
            <padding
                android:left="2dp"
                android:top="2dp"
                android:right="2dp"
                android:bottom="2dp"
/>
            <corners
                android:bottomLeftRadius="0dip"
                android:bottomRightRadius="0dip"
                android:topLeftRadius="5dip"
                android:topRightRadius="5dip"
/>
        </shape>
    </item>
</layer-list>

在实现Button圆角的设计上,主要是采用的是layer-list中的<corners>标签,该标签就是用来设置圆角的,在之前使用时,只是知道使用android:radius属性,该属性相当于就是把Button按钮的四个角都设置了圆角,而如果我们想实现上面圆角、下面直角,那么单纯的使用android:radius是不能实现的,因此必须明确的知道其实Button对应的四个角都是有相对应的设置属性的,分别是bottomLeftRadiusbuttonRightRadiustopLeftRadiustopRightRadius四个属性。

0 0
原创粉丝点击