Reputation: 141
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>
Upvotes: 14
Views: 11529
Reputation: 846
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
Upvotes: 1
Reputation: 12953
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
Upvotes: 16
Reputation: 3971
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
Upvotes: 0