FrameLayout没有正确约束。它的底部隐藏在BottomNavigationView

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

我的活动具有这种布局,它使用了多个包含RecyclerView的片段。这里的FrameLayout是片段的容器。问题是,尽管我将FrameLayout的底部设置为BottomNavigationView的顶部,但RecyclerView的最后一个元素隐藏在BottomNavigationView下。

我的活动布局代码:

<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ToolbarTheme"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:logo="@drawable/money_icon"
    />

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/toolbar"
    app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"/>

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottomNavigationView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
    app:menu="@menu/bottom_nav_menu" />

片段代码包括RecyclerView:

<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:background="@color/dark_gray"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/finishedSlipsRecycler"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

</androidx.recyclerview.widget.RecyclerView>

问题的屏幕截图:

Screenshot of the problem:

android android-recyclerview material-design android-constraintlayout bottomnavigationview
1个回答
0
投票

显然,问题出在此行上:

app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"

只需删除它,一切都会好起来的。

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