<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
app:itemIconSize="20dp"
app:itemTextAppearanceActive="@style/BottomNavigationView.Active"
app:itemTextAppearanceInactive="@style/BottomNavigationView.Inactive"
android:layout_alignParentBottom="true"
app:menu="@menu/bottom_menu"/>
i am expecting default height of the bottom navigation view.
2
Answers
I don’t know if it is the solution that you are waiting, but I solved this deleting next piece of code on my Activity.kt:
and
Another way is changing
for
If you are using this in an Activity then,
remove these following lines form the onCreate() method,
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
And Add this following lines
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val params = binding.bottomNavigationView.layoutParams as ViewGroup.MarginLayoutParams
params.bottomMargin = insets.systemWindowInsetBottom
binding.bottomNavigationView.layoutParams = params
insets.consumeSystemWindowInsets()
}
And If you are using it in a fragment then,
remove these following lines form the onCreate() method of the host activity,
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
And Add this following lines to the onViewCreated() method of the fragment
ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
val params = binding.bottomNavigationView.layoutParams as ViewGroup.MarginLayoutParams
params.bottomMargin = insets.systemWindowInsetBottom
binding.bottomNavigationView.layoutParams = params
insets.consumeSystemWindowInsets()
}
this will solve the extra space issue.