BottomNavigationView:如何删除带连字符的标签

BottomNavigationView: How to remove hypheanted labels

实施 5 项 BottomNavigationView - 始终显示标签 - 我正在使用以下方法:

<android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation"
        app:labelVisibilityMode="labeled"/>

不幸的是,结果在活动时将单词连字符,如图所示:

我尝试为标签的活动文本设置不同的样式:

app:itemTextAppearanceActive="@style/text_navigation_active_labels"

--styles.xml--

<style name="text_navigation_active_labels">
    <item name="android:breakStrategy">simple</item>
    <item name="android:hyphenationFrequency">none</item>
</style>

但结果完全一样(无论我只使用 break 策略、hyphenationFrequency 还是两者都使用)。我目前正在 API 27 物理 phone.

上测试它

感谢任何帮助。

由于 5 项可能很多 space,因此有必要妥协文本大小。为了修复它,向 BottomNavigationView 文本添加自定义样式即可完成工作:

 <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        ...
        app:itemTextAppearanceActive="@style/navTextActive"
        app:itemTextAppearanceInactive="@style/navTextInactive"/>

在 styles.xml 上:

<style name="navTextInactive">
    <item name="android:textSize">11sp</item>
</style>

<style name="navTextActive">
    <item name="android:textSize">12sp</item>
</style>

结果:

FixedNavBar

希望对大家有所帮助!