I need to hide center bottom tab in the bottom navigation while launching the app. Here I have tried to remove the tab. It worked in potrait mode, But in the landscape mode, to hide the tab bar in UI.
bottomNavigation.getMenu().removeItem(R.id.schedulers);
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/"
android:icon="@drawable/ic_bottom"
android:title="@string/all"/>
<item
android:id="@+id/tab"
android:icon="@drawable/ic_bottom"
android:title="@string/my"/>
<item
android:id="@+id/schedulers"
android:icon="@drawable/schedulers"
android:title="@string/schedulers"/>
<item
android:id="@+id/tab"
android:icon="@drawable/ic_bottom"
android:title="@string/kkk"/>
<item
android:id="@+id/tab"
android:icon="@drawable/ic_bottom"
android:title="@string/kkkk"/>
</menu>
Are you using two layout for this app like portrait and landscape?
If this is the case, immediately delete the landscape file OR add the same bottom navigation with very same id. Because I was facing on. this issue lady and finally I resolved it in this way.
If we add it in the onCreate() methods it will works fine and able to hide the tab with the code
bottomNavigation.getMenu().removeItem(R.id.schedulers)
Just use listener on navController if using nav component
navController.addOnDestinationChangedListener { _, destination, _ ->
if(destination.id == R.id.full_screen_destination) {
toolbar.visibility = View.GONE
bottomNavigationView.visibility = View.GONE
} else {
toolbar.visibility = View.VISIBLE
bottomNavigationView.visibility = View.VISIBLE
}
}