在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样式一样。

相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2021-04-11
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-10-17
相关资源
相似解决方案