Sakura

sakura

博客园 首页 新随笔 联系 订阅 管理

1. res 目录 新建一个 menu 资源文件

 

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:title="Item"/>
    <item android:title="Item"/>
    <item android:title="Item"/>
</menu>

  

然后 在 一个 fragment 中 引入

 

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

  bottom navigation view ,就是一个 导航了

 

然后 menu 的 item 要和 fragment 的 id 一致,就可以绑定 fragment了,很简单

posted on 2020-10-09 00:27  .geek  阅读(278)  评论(0编辑  收藏  举报