Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Last item covered by bottom navigation

So, I have this problem. My last item of recyclerview is covered by my bottom navigation. The bottom navigation is in activity. The recyclerview is in the fragment. I not found the answer.

Here is my fragment layout, which contain the recyclerview

<android.support.constraint.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="wrap_content"
    tools:context=".PromoFragment">

    <!-- TODO: Update blank fragment layout -->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/promo_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginBottom="110dp">

    </android.support.v7.widget.RecyclerView>
</android.support.constraint.ConstraintLayout>

Here is my item layout that I use in recyclerview

<android.support.constraint.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="wrap_content"
    android:orientation="vertical"
    android:padding="5px">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:id="@+id/card_pertama"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

               <include layout="@layout/card_promo_layout"/>

        </android.support.v7.widget.CardView>

</android.support.constraint.ConstraintLayout>

Here is the image of the result from my code

enter image description here

like image 507
bobby I. Avatar asked Apr 11 '19 09:04

bobby I.


2 Answers

Add android:paddingBottom="56dp" to your Fragment that contains RecyclerView or to the closest parent layout of RecyclerView. For example:

<android.support.constraint.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="wrap_content"
    android:paddingBottom="56dp"
    tools:context=".PromoFragment">

    <!-- TODO: Update blank fragment layout -->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/promo_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
    </android.support.v7.widget.RecyclerView>
</android.support.constraint.ConstraintLayout>

P.S. 56dp - is the height of BottomNavigationView according to Material Design. So value of paddingBottom must be the same as the height of BottomNavigationView

like image 71
Oleg Golomoz Avatar answered Sep 28 '22 02:09

Oleg Golomoz


Change your bottom Navigation into this

<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/navigationView" />

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigationView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/windowBackground"
    android:layout_alignParentBottom="true"
    app:menu="@menu/your_menu" />

And change your Layout into RelativeLayout

like image 32
Jimale Abdi Avatar answered Sep 28 '22 04:09

Jimale Abdi