【问题标题】:BottomNavigationView title hides when switching tab切换标签时BottomNavigationView标题隐藏
【发布时间】:2019-12-27 20:00:39
【问题描述】:

在选择“我的预订”时,只有我的预订可见且隐藏预订。下面是我在 XML 中的底部导航:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/navigation"
        android:layout_below="@+id/rl_custom_toolbar"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:labelVisibilityMode="labeled"
        android:background="?android:attr/windowBackground"
        app:itemBackground="@color/colorWhite"
        app:itemTextAppearanceActive="@style/itemTextAppearanceActive"
        app:itemTextAppearanceInactive="@style/itemTextAppearanceInactive"
        android:foreground="?attr/selectableItemBackground"
        app:menu="@menu/navigation"/>

</RelativeLayout>

这些是我的导航菜单 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/nav_home"
        android:icon="@mipmap/tab_home_normal"
        android:title="Home" />

    <item
        android:id="@+id/nav_message"
        android:icon="@mipmap/tab_message_normal"
        android:title="Message" />

    <item
        android:id="@+id/nav_search"
        android:icon="@mipmap/tab_search_normal"
        android:title="Search" />

    <item
        android:id="@+id/nav_bookings"
        android:icon="@mipmap/tab_my_booking_normal"
        android:title="My Bookings" />

    <item
        android:id="@+id/nav_profile"
        android:icon="@mipmap/tab_account_normal"
        android:title="Profile" />

</menu>

我尝试了一种布局行为滚动到底部导航的解决方案,但它对我不起作用。仅当我将字符串 My Bookings 缩短为 Bookings 或将标签可见性模式保持为“已选择”时才能正常工作。但这不是我的要求。我想要相同的标签字符串并且所有标签都可见。

请提供任何帮助。

【问题讨论】:

  • 我认为您遇到了与question 中所述的问题类似的问题。你可以在那里找到答案。
  • 你应该在 xml 底部导航视图中使用这个属性 app:itemTextColor="any color"
  • 不,这对我不起作用stackoverflow.com/questions/41718633/…

标签: android bottomnavigationview


【解决方案1】:

将这些添加到您的 styles.xml 以在标签处于活动状态和非活动状态时更改它们的文本大小:

<dimen name="design_bottom_navigation_text_size" tools:override="true">12sp</dimen>
<dimen name="design_bottom_navigation_active_text_size" tools:override="true">12sp</dimen>

【讨论】:

  • 我不需要在某个地方应用这个吗??
  • 把它放在你的AppTheme
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多