Solution 1 :
Make the height of your fragment tag that hold nav host fragment 0dp
In your activity_main.xml
<fragment
android_layout_marginTop="130dp"
android_id="@+id/dataContainer"
android_name="androidx.navigation.fragment.NavHostFragment"
android_layout_width="409dp"
android_layout_height="673dp" ---------> ( make it 0dp )
app_defaultNavHost="true"
app_layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toBottomOf="@id/mainToolbar"
app_navGraph="@navigation/my_nav" />
Problem :
I have an issue with placing fragment and making it scroll without being overlapped by bottomNavigationView and AppBar. So my content is covered by BottomNavigationView and AppBar.How i can make my content visible when I am scrolling page or appBar and BottomNavigationView invisible while scrolling page down?
my activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_app="http://schemas.android.com/apk/res-auto"
android_id="@+id/drawerLayout"
xmlns_tools="http://schemas.android.com/tools"
android_layout_width="match_parent"
android_layout_height="match_parent"
tools_context=".activities.MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android_layout_width="match_parent"
android_layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android_theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android_id="@+id/mainToolbar"
style="@style/mainToolbar"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintHorizontal_bias="0.0"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toTopOf="parent"
android_elevation="0dp"
/>
<View
android_layout_width="match_parent"
android_layout_height="8dp"
app_layout_constraintBottom_toTopOf="@id/bottomNavigationView"
android_background="@drawable/shadow"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android_id="@+id/bottomNavigationView"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_background="#fff"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintHorizontal_bias="1.0"
app_layout_constraintStart_toStartOf="parent"
app_menu="@menu/bottom_menu"/>
<fragment
android_layout_marginTop="130dp"
android_id="@+id/dataContainer"
android_name="androidx.navigation.fragment.NavHostFragment"
android_layout_width="409dp"
android_layout_height="673dp"
app_defaultNavHost="true"
app_layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toBottomOf="@id/mainToolbar"
app_navGraph="@navigation/my_nav" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android_id="@+id/navView"
android_layout_width="wrap_content"
android_layout_height="match_parent"
app_headerLayout="@layout/nav_header"
app_menu="@menu/nav_drawer_menu"
android_layout_gravity="start"
android_fitsSystemWindows="true" />
</androidx.drawerlayout.widget.DrawerLayout>
Is there any solutions?