AndroidX BottomNavigationView - PullRequest
       8

AndroidX BottomNavigationView

0 голосов
/ 04 ноября 2019

В настоящее время я разрабатываю приложение для Android, и с BottomNavigationView есть одно мероприятие. У меня есть некоторые проблемы с этим. Контент не отображается, хотя я указал файл меню из папки res. Кажется, что моя панель навигации по-прежнему имеет высоту, равную 0dp. Вот мой файл меню в каталоге res / menu:

 <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/nav_home"
        android:icon="@drawable/ic_home_icon"
        android:title="@string/nav_home"/>
    <item
        android:id="@+id/nav_notification"
        android:icon="@drawable/ic_notification_icon"
        android:title="@string/nav_notification"/>
    <item
        android:id="@+id/nav_schedule"
        android:icon="@drawable/ic_schedule_icon"
        android:title="@string/nav_schedule"/>
    <item
        android:id="@+id/nav_profile"
        android:icon="@drawable/ic_profile_icon"
        android:title="@string/nav_profile"/>
</menu>

А вот мой xml-файл активности:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".HomeActivity">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/bottom_nav"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Зависимости, модуль приложения:

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.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...