移除 BottomNavigationView 中的顶部填充

Remove the top padding in BottomNavigationView

我有一个 BottomNavigationView 显示所选项目的背景

这是底部导航XML:

<com.google.android.material.bottomnavigation.BottomNavigationView
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="bottom"
            app:itemBackground="@drawable/bottombar_item_bg"/>

我希望项目与条形高度匹配并删除显示的顶部填充。

如果我理解你是真的 android:layout_height="?attr/actionBarSize" 这里你将高度设置为 50dp 所以尝试将高度更改为 android:layout_height="35dp" or android:layout_height="40dp"