I need to hide title of items in bottom navigation bar
Asked Answered
S

3

14

I create bottom navigation bar and i need to hide title and show icons only but when i write title with empty string there is big space between icon and bottom it just replace string with empty string and i make many search but i don't found solutions so any help

<?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>

navigation.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>
Silda answered 7/2, 2018 at 9:26 Comment(2)
Please refer the link #40183739Soybean
#40183739 Try here!Aurilia
H
16

Starting from support library 28.0.0-alpha1, you can use:

app:labelVisibilityMode="unlabeled"

to hide title and

app:itemHorizontalTranslationEnabled="false"

add:

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

to disable shift mode to your BottomNavigationView in xml

Hoplite answered 11/7, 2018 at 13:21 Comment(0)
K
1

You can use following property of BottomNavigationView:

app:labelVisibilityMode="unlabeled"

also include following line in you layout:

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

For reference you can use following link: https://www.11zon.com/zon/android/remove-bottom-navigation-view-title-in-android.php

Kylynn answered 8/10, 2021 at 5:25 Comment(0)
C
0

The BottomNavigationView have a lot of limitations.

You can set the title with an empty String "" for example but I recommend you to use a library for enhancing the bottom navigation bar easily.

You can try this one : https://github.com/ittianyu/BottomNavigationViewEx

Co answered 7/2, 2018 at 9:41 Comment(1)
How to change the icon if I select another tab? Mine cannot changeAha

© 2022 - 2024 — McMap. All rights reserved.