Search code examples
androidmenubottomnavigationview

Why my Bottom Navigation View does not show any titles or icons?


Here is my Bottom Navigation View in activity_main.xml:

    <com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="?android:attr/windowBackground"
android:backgroundTint="#1091BF"
app:itemIconTint="#fff"
app:itemTextColor="#fff"
app:menu="@menu/navigation_bottom" />

Here is my Bottom Navigation Menu in navigation_bottom.xml:

<?xml version="1.0" encoding="utf-8"?>

<item
    android:id="nav_home"
    android:icon="@drawable/ic_navigation_24dp"
    android:title="@string/home"/>

<item
    android:id="nav_education"
    android:icon="@drawable/ic_school_24dp"
    android:title="@string/education"/>

<item
    android:id="nav_report"
    android:icon="@drawable/ic_report_24dp"
    android:title="@string/report"/>

<item
    android:id="nav_activity"
    android:icon="@drawable/ic_activity_24dp"
    android:title="@string/activity"/>

<item
    android:id="nav_profile"
    android:icon="@drawable/ic_person_24dp"
    android:title="@string/profile"/>

Here is my dependencies in the build.gradle(Module:app):

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

//Added code
//Navigation Dependencies
def nav_version = "2.1.0"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"}

I don't understand why my Bottom Navigation View doesn't show anything. On the design tab in activity_main.xml, it doesn't even have any height when I choose wrap_content to the layout_height.


Solution

  • See this: LabelVisibilityMode set your app:labelVisibilityMode to labeled