android用shape画一条横线

在drawable目录下新建shape

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- This is the line -->
    <!-- left 和right是左右边距 -->
    <item
        android:left="1dp"
        android:right="1dp">
        <shape>
            <solid android:color="@color/colorPrimaryDark" />
        </shape>
    </item>
    <!--bottom是横线高度 -->
    <item android:bottom="2dp">
        <shape>
            <solid android:color="@color/white" />
        </shape>
    </item>

</layer-list>

android用shape画一条横线

效果如下

android用shape画一条横线

使用方法 和正常使用drawble样式一样。