I use fragments for the bottom navigation.
I have defined a theme with the parent Theme.MaterialComponents.NoActionBar.Bridge.
It works fine on activities, but the fragments show a gap.
This is the BottomNavigationActivity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
firebaseAnalytics = FirebaseAnalytics.getInstance(this)
val user = userFromIntent
initGoogleSignInClient()
binding = ActivityBottomNavigationMenuBinding.inflate(layoutInflater)
setContentView(binding.root)
val navView: BottomNavigationView = binding.navView
val navController = findNavController(R.id.nav_host_fragment_activity_main)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.navigation_home, R.id.navigation_activities, R.id.navigation_more
)
)
navView.setupWithNavController(navController)
}
An excerpt from MoreFragment.
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
fragmentMoreBinding = FragmentMoreBinding.inflate(inflater, container, false)
Any ideas? I have tried something similar to this:
((AppCompatActivity) getActivity()).getSupportActionBar().hide();
Removed android:paddingTop="?attr/actionBarSize on the XML I have the nav_host_fragment_activity_main and it worked!