1

I have a recyclerview which should be behind a custom tab bar.

Everything works perfect except for the fact that the list item at the bottom of the view is mostly hidden by the tab bar.

Is there a way that I can "shorten" the height of the recyclerview so that the list item isn't hidden behind the tab bar.

Here is the XML for the Dashboard

<RelativeLayout 
    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="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".Fragments.Dashboard" > 

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

And the BottomNavBar

<androidx.coordinatorlayout.widget.CoordinatorLayout
    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="match_parent"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/fragment_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:fabCradleMargin="20dp"
        app:fabCradleVerticalOffset="10dp"
        app:fabCradleRoundedCornerRadius="20dp"
        android:layout_gravity="bottom" >

    

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginEnd="16dp"
        android:background="@android:color/transparent"
        app:menu="@menu/bottom_nav_menu" />

</com.google.android.material.bottomappbar.BottomAppBar>

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_anchor="@id/bottomAppBar" />
    <!-- android:src="@drawable/ic_add" -->

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Zain
  • 37,492
  • 7
  • 60
  • 84
Learn2Code
  • 1,974
  • 5
  • 24
  • 46
  • Do you mean by the `tab bar` the [`BottomNavView`](https://material.io/components/bottom-navigation/android)? – Zain Jul 09 '21 at 01:16
  • @Zain yes, sorry in iOS its referred to a tab bar. – Learn2Code Jul 09 '21 at 01:18
  • It depends.. If you are using `ConstraintLayout` then you can constraint the bottom of the `RecyclerView` to the top of the BottomNavView.. Some other types of layouts can be dealt differently.. If you can you share the layout.. it would be more clear – Zain Jul 09 '21 at 01:23
  • This should be a fragment and the `BottomNavView` in the main activity I guess? – Zain Jul 09 '21 at 01:29
  • @Zain I am using Fragments, can you please expand on your comment, I'm new to Android and am learning the ropes sort of speak. – Learn2Code Jul 09 '21 at 01:34
  • You can add `android:layout_marginBottom="60dp"` to `FrameLayout` .. The height of the bottomNavView is 56dp exactly, increasing it a bit for more appealing – Zain Jul 09 '21 at 01:40
  • 1
    @Zain Nailed it!!! Thank you for the answer!!! – Learn2Code Jul 09 '21 at 01:42

1 Answers1

1

You can add android:layout_marginBottom="60dp" to FrameLayout which is the fragments' placeholder.

The height of the BottomNavView is 56dp exactly, increasing it a bit for more appealing (to be 60dp)

Zain
  • 37,492
  • 7
  • 60
  • 84