使用recyclerView时如何修复底部导航栏?

问题描述 投票:0回答:1

我正在设计一个带有回收器视图和底部导航栏的页面,但问题是底部导航栏隐藏在底部,当我向上滚动回收器视图时,底部导航栏是可见的。我已经尝试了所有我能想到的方法,我使用了协调器布局、线性布局、相对布局和框架布局,但在每种情况下,输出都是相同的。

下面是我最近尝试过的带有约束布局的 xml 代码,但问题仍然相同。

<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=".fragment.BiteBackCommunityFragment">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerViewCommunity"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="8dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintBottom_toTopOf="@id/bottomNav"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:menu="@menu/bottom_nav_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>

请帮助我,因为我从昨天开始就试图解决这个问题。顺便说一句,我正在片段中设计这个 UI。

谢谢!!

android xml user-interface android-recyclerview bottomnavigationview
1个回答
0
投票

因为你的

recyclerView
设置为延伸到父级的末尾。

    app:layout_constraintEnd_toEndOf="parent"

删除它应该将您的 RecyclerView 扩展到底部栏上方

© www.soinside.com 2019 - 2024. All rights reserved.