I tried Google Support Library BottomNavigationView with a Framelayout for my Fragments .
Here are my code
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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"
android:fitsSystemWindows="true"
tools:context="com.bottombarnavigation.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<include layout="@layout/toolbar"/>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.BottomNavigationView
android:background="#fcfcfc"
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:menu="@menu/bottom_navigation" />
</android.support.design.widget.CoordinatorLayout>
When i populate my Recyclerview inside the Fragment, it's content got covered up by the BottomNavigationView .
I have no idea why this happens. I look through other people tutorial and it works fine.
EDIT Here is my content_main.xml file
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.bottombarnavigation.MainActivity"
tools:showIn="@layout/activity_main">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
</RelativeLayout>
Here my solution, is working for me.
I have almost the same layout as you, I moved the
BottomNavigationView
out of theCoordinatorLayout
as I don't need any animation on it. I've alignedBottomNavigationView
to the parent's bottom, and addedlayout_above
toCoordinatorLayout
to have it above theBottomNavigationView
but filling all the screen.With this configuration I fixed the overlapping issue, I hope this would help you.
Here you have my layout.