Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to hide title of items in bottom navigation bar

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>
like image 363
Maysa Khamis Avatar asked Feb 07 '18 09:02

Maysa Khamis


People also ask

How do I use the bottom navigation bar without the label?

In the BottomNavigationBar set the “selectedFontSize” to 0. Then set the BottomNavigationBarItem “label” property to empty string. ); Voila!

How do I hide my navigation buttons?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.


1 Answers

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

like image 163
Nongthonbam Tonthoi Avatar answered Oct 24 '22 08:10

Nongthonbam Tonthoi