【问题标题】:Bottom Navigation View overlaps last item of RecyclerView底部导航视图与 RecyclerView 的最后一项重叠
【发布时间】:2019-03-15 14:02:56
【问题描述】:

RecyclerView 的最后一项被 BottomNavigationView 重叠。描述和时间被BottomNavigationView重叠。

framgment_news.xml:这包含我的 RecyclerView

<android.support.constraint.ConstraintLayout ...
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragments.NewsFragment"
android:background="#fff">

<ImageView
    android:id="@+id/imageView" ... />

<TextView
    android:id="@+id/textView" ... />

<TextView
    android:id="@+id/textView3" ... />

<TextView
    android:id="@+id/textView2" ... />

<com.mikhaellopez.circularimageview.CircularImageView
    android:id="@+id/circularImageView" ... />

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="12dp"
    app:layout_constraintTop_toBottomOf="@+id/textView3"
    tools:layout_editor_absoluteX="0dp"
    android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>

activity_home.xml

<android.support.constraint.ConstraintLayout ...
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".HomeActivity">

    <FrameLayout
        android:id="@+id/frameContainer"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginStart="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginEnd="0dp"
        app:layout_constraintBottom_toTopOf="@+id/view"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:layout_above="@+id/bottom_navigation_view"
        app:layout_constraintTop_toTopOf="parent" />

    <!--Border on Top of Bottom Navigation View-->
    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:background="#616161"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff"
        app:labelVisibilityMode="unlabeled"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/bottom_navigation_menu" />

</android.support.constraint.ConstraintLayout>

The last item of RecyclerView being overlapped by BottomNavigationView

【问题讨论】:

  • 为 RecyclerView 使用 padding 底部或 margin 底部

标签: android android-recyclerview overlap bottomnavigationview


【解决方案1】:

为 RecyclerView 的父布局添加 padding

<android.support.constraint.ConstraintLayout ...
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="56dp"
    tools:context=".Fragments.NewsFragment"
    android:background="#fff">

并根据 Material Design 改变 BottomNavigationView 的高度

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation_view"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="#fff"
    app:labelVisibilityMode="unlabeled"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:menu="@menu/bottom_navigation_menu" />

【讨论】:

    【解决方案2】:

    您应该将加载片段的容器视图附加到底部导航视图的顶部。 这样,如果您在容器视图中加载任何内容,它就不会进入底部导航视图。

    app:layout_constraintEnd_toEndOf="parent"
    

    这部分代码,在你的框架布局中,应该是

    app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
    

    只需使用已有的约束布局,从框架布局中移除底部约束并将其附加到bottomNavigationView的顶部!

    【讨论】:

      【解决方案3】:

      在您的activity_home.xml 中,您可以使用RelativeLayout。并在 FrameLayout 中设置android:layout_above="@+id/bottom_navigation_view"

      【讨论】:

        【解决方案4】:

        如果以上都没有解决您的问题..将您的片段布局放在滚动视图或嵌套滚动视图中..还在片段的约束布局中使用android:fillViewport="true"。 `

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-04-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-01-01
          • 2021-04-27
          • 2023-03-08
          相关资源
          最近更新 更多