Big*_*air 5 android bottomnavigationview android-bottomnav
截至最近,底部导航栏开始在文本和图标之间包含一些奇怪的空间(我认为在更新依赖项之后):
现在图标和文本之间似乎有一个间隔符,它将两者推到了栏的最末端。到目前为止,我发现的只是尝试app:itemPaddingTop
手动将图标推回原处,但这会破坏较小设备上的视图。
这是 XML:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?android:attr/windowBackground"
app:itemBackground="@color/darkGalaxy"
app:itemIconTint="@color/bottom_nav_color_selector"
app:itemTextColor="@color/bottom_nav_color_selector"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_default="percent"
app:layout_constraintHeight_percent="0.1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
Run Code Online (Sandbox Code Playgroud)
有没有办法让它们都以最小的边距垂直居中?
经过一番测试,发现是因为我设置的自定义高度的原因app:layout_constraintHeight_percent="0.1"
。将条形拉伸得比它更高会奇怪地间隔内容,就像这样(几个月前我第一次制作它时不是这样的)。
不管怎样,我在那里只有这个基于百分比的高度,因为android:layout_height="wrap_content"
在底部导航栏上使用使它占据了大部分屏幕。但通过测试我发现这只是因为我使用了android:background="?android:attr/windowBackground"
. 我不记得为什么使用它,但删除它可以wrap_content
工作。