android - 如何将第二行添加到 Android 底栏上的文本?

标签 android android-bottomnav bottombar

我正在尝试将我的文本放到第二行,这样它就不会被截断,但不确定使用 Google MaterialBottomBar 是否可行? 请像下面的图片一样。

enter image description here

但这就是我所拥有的:

enter image description here

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/white"
        app:labelVisibilityMode="labeled"
        app:itemIconTint="@drawable/nav_items_color"
        app:itemTextColor="@drawable/nav_items_color"
        app:menu="@menu/bottom_menu_nav" />

谢谢。

最佳答案

style.xml 中为 BottomNavigation 添加样式

<style name="BottomNavigationStyle">
        <item name="android:lines">2</item>
    </style>

然后在你的xml中使用上面的样式

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/white"
        app:labelVisibilityMode="labeled"
        app:itemIconTint="@drawable/nav_items_color"
        app:itemTextColor="@drawable/nav_items_color"
        android:theme="@style/BottomNavigationStyle"
        app:menu="@menu/bottom_menu_nav" />

关于android - 如何将第二行添加到 Android 底栏上的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62981668/

相关文章:

java - Android:如何从监听器调用 Activity 的方法

Android调整作为base64字符串接收的大图像

如果 Android 应用程序闲置几个小时会自动退出

java - 如何从 String[] 数组填充 Point[] 数组?

Android底部导航栏自定义

android - 底部导航 View 。使用深层链接导航到目的地导致也在第一个选项卡中添加目的地 fragment

android - 底部导航 fragment 内的多个 Tab fragment

android - 为什么我的 BottomBar 位于屏幕中间?

android - 如何使用 Lottie 动画文件作为滑动的占位符

android - 选择时更改 Android BottomBar 图标