gpt4 book ai didi

安卓底部导航 View : too much space between icon and text

转载 作者:行者123 更新时间:2023-12-05 04:29:42 25 4
gpt4 key购买 nike

最近底部导航栏开始在文本和图标之间包含一些奇怪的空间(我想是在我更新依赖项之后):

enter image description here
(颜色为红色以查看边界)

现在图标和文本之间似乎有一个间隔符,将两者都推到了栏的两端。到目前为止我发现的是使用 app:itemPaddingTop 尝试手动将图标向下推,但这会破坏较小设备上的 View 。

这是 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" />

有没有办法让它们都垂直居中且边距最小?

基本上看起来像这样:
enter image description here

最佳答案

经过一些测试,我发现这是因为我使用 app:layout_constraintHeight_percent="0.1" 设置的自定义高度。将条形图拉得比它高会像这样奇怪地分隔内容(几个月前我第一次制作它时不是这样的)。

无论如何,我只有这个基于百分比的高度,因为在底部导航栏上使用 android:layout_height="wrap_content" 使其占据了大部分屏幕。但是通过测试我发现这只是因为我使用了android:background="?android:attr/windowBackground"。我不记得我为什么使用它,但是删除它可以使 wrap_content 工作。

关于安卓底部导航 View : too much space between icon and text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72250744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com