首页 > 解决方案 > 我不能使用 labelVisibilityMode

问题描述

即使我已经添加了依赖设计,我也不明白为什么会发生这种情况?

我的错误

我的错误..

我的依赖

我的来源

我尝试这样做,但有些东西显示另一个错误

标签: androiddependenciesbottomnavigationview

解决方案


尝试使用新的material.io 2.0和androidx ..试试这个代码..

<?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"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent">

<include
    android:id="@+id/amToolbar"
    layout="@layout/app_toolbar"
    />

<FrameLayout
    android:id="@+id/activity_main_container"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    app:layout_constraintTop_toBottomOf="@+id/amToolbar"
    app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
     />

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:labelVisibilityMode="labeled"
    app:layout_constraintBottom_toBottomOf="parent"
    app:menu="@menu/bottom_menu" />

 </androidx.constraintlayout.widget.ConstraintLayout>

请参阅此链接 https://material.io/design/components/bottom-navigation.html


推荐阅读