Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android my bottom app a bar is overlapping my recyclerview

I am trying to fix this issue where my recyclerview is overlapped by bottomappbar. Here is my layout code .

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:id="@+id/notes_container_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
     >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:padding="8dp"
            android:text="@string/myTasksHeader"
            android:textColor="@color/appBarTextColor"
            android:textSize="40dp" />

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recyclerview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipToPadding="false"
                android:padding="16dp"
                android:scrollbars="none"
                tools:listitem="@layout/note_list_item" />
        </ScrollView>

    </LinearLayout>

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:backgroundTint="@color/colorPrimary"
        app:hideOnScroll="false"
        app:menu="@menu/appbar_menu"
        app:navigationIcon="@drawable/ic_menu" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/add_note_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/medium_margin"
        android:backgroundTint="@color/colorPrimary"
        app:layout_anchor="@id/bottomAppBar"
        app:srcCompat="@drawable/ic_add_black_24dp"
        tools:ignore="VectorDrawableCompat" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

when I fill my list I cant reach my last item in the recycler view. I tried adding margin but it did not work.

enter image description here

like image 207
NinjaXX2 Avatar asked Dec 11 '25 07:12

NinjaXX2


2 Answers

Two ways to achieve this

  1. Hide BottomAppBar layout while scrolling ..

    Add following attribute inside BottomAppBar

            app:fabAlignmentMode="center"
            app:fabCradleMargin="10dp"
            app:fabCradleRoundedCornerRadius="10dp"
            app:hideOnScroll="true"
    
  2. If you do not want to hide BottomAppBar then add margin from bottom in RecyclerView

    android:layout_marginBottom="?actionBarSize"
    
like image 131
chand mohd Avatar answered Dec 12 '25 22:12

chand mohd


The problem with using margin is that the RecyclerView won't show through the FAB. A better solution than using margin would be to add extra space at the bottom of the RecyclerView using padding.

android:clipToPadding="false"
android:paddingBottom="?actionBarSize" 
like image 25
Aura Lee Avatar answered Dec 12 '25 22:12

Aura Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!