首页 > 解决方案 > BottomNavigationView 覆盖 Listview 中的最后一项

问题描述

这是我的 ListView 布局:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.spccheck.CheckSPCFragment">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        tools:ignore="MissingConstraints">

        <ListView
            android:id="@+id/listviewspc2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="@android:color/holo_blue_light"
            android:dividerHeight="1.0sp"
            >
        </ListView>

    </RelativeLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottom_navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_below="@+id/listviewspc2"
            android:background="@color/colorPrimaryDark"
            app:itemBackground="@color/colorPrimaryDark"
            app:itemIconTint="@android:color/white"
            app:itemTextColor="@android:color/white"
            app:menu="@menu/bottom_nav_menu" />
    </FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

当列表包含很多项目时,最后一个显示一半,因为底部导航覆盖了它。如何将列表视图设置为底部导航上方?

标签: androidlistviewbottomnavigationview

解决方案


推荐阅读