Kirk Charles
Kirk Charles

Reputation: 53

Bottom Navigation View overlaps last item of RecyclerView

The last item of RecyclerView is being overlapped by BottomNavigationView. The description and time is being overlapped by BottomNavigationView.

framgment_news.xml: This contains my 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

Upvotes: 5

Views: 4017

Answers (4)

sum20156
sum20156

Reputation: 734

if none of the above solved your problem..put your fragment layout in scrollview or nested scrollview..also use android:fillViewport="true" in constraint layout of fragment. `

Upvotes: 0

SoulaimenK
SoulaimenK

Reputation: 644

In your activity_home.xml, you can use RelativeLayout. And set android:layout_above="@+id/bottom_navigation_view" in the FrameLayout.

Upvotes: 0

Oleg Golomoz
Oleg Golomoz

Reputation: 532

Add padding to the parent layout of RecyclerView

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

And change the height of BottomNavigationView according to Material Design

<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" />

Upvotes: 5

Matteo Alberghini
Matteo Alberghini

Reputation: 66

You should attach the container view where you load your fragments to the top of the bottom navigation view. This way, if you load anything in the container view it won't go under the bottom navigation view.

app:layout_constraintEnd_toEndOf="parent"

this part of the code, inside your frame layout, should be

app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"

Just use the constraint layout you already have, remove the bottom constraint from the frame layout and attach it to the top of bottomNavigationView!

Upvotes: 2

Related Questions