I am having my bottom navigation view inside a fragment. Below is the code


<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"
    tools:context=".fragments.investors.InvestmentParentFragment">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemIconTint="@drawable/nav_selector"
        app:itemTextColor="@drawable/nav_selector"
        app:menu="@menu/investments_bottom_nav_menu"
        android:layout_gravity="bottom"
        android:layout_alignParentBottom="true"
        app:itemRippleColor="@color/secondaryLightColor"
        android:background="@drawable/bottom_nav_background"
        />

</RelativeLayout>

When i click on an item in the bottom navigation view it navigates to a fragment. The problem am having is that when i navigate to a new fragment it opens the new fragment and the bottom navigation view disappears i would like it to work like the way where the bottom navigation view is in MainActivity and when i navigate to a new fragment it does not disappear it stays there and can operate like a tab layout

Here is what i have tried so in the fragment having the bottom navigation view but its not working. Inside onViewCreated method


 Navcontroller navController = Navigation.findNavController(view); 

 bnvInvestments = view.findViewById(R.id.bnv_investments);

 NavigationUI.setupWithNavController(bnvInvestments, navController);



0

There are 0 answers