5

I want to make BottomNavigationView Menu in UpperCase, How can i do that without using 3rd party library?

Here is my xml code:

<android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@android:color/white"
        android:foreground="?attr/selectableItemBackground"
        app:itemIconTint="@color/bottom_nav_color"
        app:itemTextColor="@color/bottom_nav_color"
        app:menu="@menu/navigation" />

And navigation.xml as follows:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/home_icon"
        android:title="@string/title_home"
        />

    <item
        android:id="@+id/navigation_deals"
        android:icon="@drawable/ic_deals"
        android:title="@string/deals" />

    <item
        android:id="@+id/navigation_myBookings"
        android:icon="@drawable/ic_my_bookings"
        android:title="@string/title_my_bookings" />

   <item
        android:id="@+id/navigation_more"
        android:icon="@drawable/ic_more"
        android:title="@string/title_more" />
</menu>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Karan Kalsi
  • 789
  • 3
  • 21

2 Answers2

8

Try this

Create a style like this BottomNavigationViewStyle

<style name="BottomNavigationViewStyle">
    <item name="android:textAllCaps">true</item>
    <item name="android:textSize">15sp</item>
</style>

Than use like this

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom"
    android:background="@android:color/white"
    android:foreground="?attr/selectableItemBackground"
    app:menu="@menu/navigation"
    app:theme="@style/BottomNavigationViewStyle" />

OUTPUT

enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

Apply this theme to your bottom navigation

<style name="AppTheme2" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:textAllCaps">true</item>
</style>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Amir Dora.
  • 2,831
  • 4
  • 40
  • 61