android - BottomNavigationView:更改标题和图标之间的间隙大小

标签 android xml bottomnavigationview

我想更改BottomNavigationView高度和更改尺寸后项目位置不会改变。

这更像是中间的间隙不会自动改变。但是,我想更改这个间隙大小。

This is Before change height and item sizes. These gap sizes are fine with these items but making item smaller it will make a UI issue. enter image description here

And these one is After enter image description here

这是我的代码:

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/nav_view"
    style="@style/MyBottomNavigationView"
    android:layout_width="0dp"
    android:layout_height="?android:listPreferredItemHeightSmall"
    android:background="?android:attr/windowBackground"
    app:itemIconSize="20dp"
    app:labelVisibilityMode="labeled"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/bottom_nav_menu" />

我也在使用<com.google.android.material.bottomnavigation.BottomNavigationView ...如果你们知道更好的库,请推荐我。

最佳答案

通过覆盖以下尺寸来更改 BottomNavigationView 的高度

<dimen name="design_bottom_navigation_height" tools:override="true">40dp</dimen>

这将增加/减少图标和文本之间的间隙大小。

引用:material-components-android

关于android - BottomNavigationView:更改标题和图标之间的间隙大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66570683/

相关文章:

java - 在泛型方法java中传递类类型

android - 屏幕关闭和打开时理解生命周期的问题

Android studio git 消息 : following untracked working tree files would be overwritten by merge, 但未显示哪些文件

xml - 处理XSLT命名空间不匹配

android - BottomNavigationView 图标上方显示的导航项文本

android - 在我的特殊情况下,logcat 不显示来自库项目的日志

java - 如何关闭底部导航或调用另一个空 Activity ?

c# - 如何从 XElement 获取字符串形式的 XML 片段?

android - 使用 BottomAppBar 或 BottomNavigationView 创建自定义底部 View

android - 为什么底部抽屉导航 fragment 显示空数据