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

标签 android bottomnavigationview

升级依赖后:

'com.google.android.material:material:x.x.x'


来自 1.4.0 1.5.0 ,导航项文本以某种方式从锚定在图标下方更改为在图标上方:
从:
enter image description here
至:
enter image description here
这是一个功能还是一个错误,这有修复吗?

最佳答案

从 1.4.0 更新到 1.5.0 后,我遇到了同样的问题,但在我的情况下,问题是因为我使用继承自 Widget.Design.BottomNavigationView 的 BottomNavigationView 的主题引起的。 :

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bnv"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/windowBackground"
    android:theme="@style/Widget.BottomNavigationView"
    ...
/>
看完Widget.Design.BottomNavigationView xml 我意识到在版本 1.5.0 中是 minHeight属性已添加,导致影响我们的问题。
所以我加了<item name="android:minHeight">0dp</item>我的自定义样式是这样的:
<style name="Widget.BottomNavigationView" parent="Widget.Design.BottomNavigationView">
    ...
    <item name="android:minHeight">0dp</item>
</style>
问题就解决了!

关于android - BottomNavigationView 图标上方显示的导航项文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70728720/

相关文章:

android - 隐藏按钮的动画

android - 如何获取 ExpandableListView 在 Android 上可绘制的组指示器的宽度?

android - 如何在 Jetpack Compose 中使小部件不可见?

javascript - BottomNavigationView 的菜单未选择

android - 在 CoordinatorLayout 中排列 BottomNavigationView、FAB 和 FrameLayout,并使其与 Snackbar 一起使用

java - 通过 Android 应用程序在网络服务器上上传多个文件

android - fragment 到 fragment 的事务很慢

android - 为什么 fragment 被多次添加到后台堆栈

android - BottomNavigationView 滞后于 fragment 事务

android - 使用设计支持库的android底部导航菜单中超过3个项目