尝试在我的应用中添加底部导航视图

时间:2020-05-11 13:31:01

标签: android androidx bottomnavigationview

嘿,在我的应用程序中添加底部导航视图非常麻烦。 我已经在我的build.gradle文件中添加了以下依赖项:

implementation 'com.google.android.material:material:1.1.0'

这是我在activity_main.xml中的代码

  <?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:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity">


<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/btmnav"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:menu="@menu/bottom_navigation"
    android:background="?android:attr/windowBackground"
    />

    </RelativeLayout>

我的菜单资源文件:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
     android:id="@+id/live"
     android:icon="@drawable/ic_live_tv_black_24dp"
     android:title="Live"/>
     <item
     android:id="@+id/schedule"
     android:icon="@drawable/ic_schedule_black_24dp"
     android:title="Schedule"/>
     <item
     android:id="@+id/feed"
     android:icon="@drawable/ic_rss_feed_black_24dp"
     android:title="Feed"/>
     <item
     android:id="@+id/squad"
     android:icon="@drawable/ic_team_squad_black_24dp"
     android:title="Squad"/>

      </menu>

但是我的设计选项卡中什么都没有出现,它没有显示底部导航视图:

a image from the design tab

我已经为此奋斗了几个小时.....我该怎么办?

TIA!

0 个答案:

没有答案