簡體   English   中英

如何在android中使用底部導航欄獲取sidenav?

[英]How to get sidenav from using bottom navigation bar in android?

我想開發一個應用程序,我將在其中使用底部導航欄,當用戶選擇選項時,它將顯示側邊欄,如下圖所示,來自左側或右側,但選項按鈕將位於底部導航欄中。

導航欄:

在此處輸入圖片說明

首先,您必須創建一個導航視圖和底部導航欄。

導航視圖

<com.google.android.material.navigation.NavigationView
    android:id="@+id/navigationView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:headerLayout="@layout/drawer_header"
    app:menu="@menu/menu_drawer"
    android:layout_gravity="start"/>

底部導航欄

<com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNavigation"
            android:layout_width="match_parent"
            android:layout_height="55dp"
            style="@style/Widget.MaterialComponents.BottomNavigationView.Colored"
            android:layout_alignParentBottom="true"
            app:menu="@menu/bottom_navigation_menu"
            android:background="@color/colorPrimaryDark"
            app:itemTextColor="@color/white"
            app:labelVisibilityMode="labeled"/>

現在要打開抽屜,您必須像這樣在 setOnNavigationItemSelectedListener 中設置抽屜布局(這將是父布局)

bottomNavigation.setOnNavigationItemSelectedListener{
      when(it.itemId){
          R.id.your_bottom_menu_selected_id->{
                drawer_layout_id.openDrawer(navigationView)
          }
      }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM