在底部导航视图中选择的每个项目下方添加一行

我要在选择“底部导航视图项目”的每个项目下方放置一个ligne。如下图所示,但我找不到解决方法。 我创建如下形状线line.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke android:width="6dp" android:height="2dp" android:color="@color/honey"/>
    <corners android:radius="5dp"/>
</shape>

然后创建一个选择器checked_uncheked.xml,如下代码:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/line" android:state_checked="true"/>
    <item android:drawable="@color/white" android:state_checked="false"/>
</selector>

我在bottomNavigation下面添加了"app:itemBackground="@drawable/line",但仍然没有结果

在底部导航视图中选择的每个项目下方添加一行

XXQJING 回答:在底部导航视图中选择的每个项目下方添加一行

使用此line.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:left="32dp"
        android:right="32dp"
        android:top="32dp">
        <shape android:shape="line">
            <stroke android:width="6dp" android:height="2dp" android:color="@color/honey"/>
            <corners android:radius="5dp"/>
        </shape>
    </item>
</layer-list>

根据您的布局调整边距。

本文链接:https://www.f2er.com/3028651.html

大家都在问