我需要隐藏底部导航栏中项目的标题。

14

我创建了底部导航栏,我需要隐藏标题并仅显示图标,但当我使用空字符串写标题时,图标与底部之间有很大的空间。它只是用空字符串替换了字符串,并且我进行了许多搜索,但我没有找到解决方案,所以需要任何帮助。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.easyschools.student.HomeActivity">

<FrameLayout
    android:id="@+id/main_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/navigation"
    android:layout_alignParentTop="true">
 </FrameLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="0dp"
    android:layout_marginStart="0dp"
    android:background="@android:color/white"
    android:layout_alignParentBottom="true"
    app:menu="@menu/navigation"/>

</RelativeLayout>

导航.xml

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

    <item
        android:id="@+id/nav_messages"
        android:icon="@drawable/msg_icon"
        android:title=""/>

    <item
        android:id="@+id/nav_home"
        android:icon="@drawable/home_icon"
        android:title=""
        android:checked="true"/>

    <item
        android:id="@+id/nav_notify"
        android:icon="@drawable/notify_icon"
        android:title=""/>

    <item
        android:id="@+id/nav_my_profile"
        android:icon="@drawable/user_icon"
        android:title=""/>
</menu>

请参考以下链接:https://dev59.com/7FkS5IYBdhLWcg3wN0PA - Arya
请点击此处查看如何移除BottomNavigationView标签。 - A.Turner
3个回答

16

从支持库28.0.0-alpha1开始,您可以使用:

app:labelVisibilityMode="unlabeled"

隐藏标题和

app:itemHorizontalTranslationEnabled="false"

添加:

xmlns:app="http://schemas.android.com/apk/res-auto"

在xml中禁用BottomNavigationView的shift mode


1

0

如何在选择其他选项卡时更改图标?我的不能更改。 - Jeff Bootsholz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接