简体   繁体   English

添加带有底部导航栏的导航抽屉

[英]Add Navigation Drawer with Bottom Navigation Bar

In my app there is Bottom Navigation Bar i want to add Navigation Drawer because there is many buttons that dont fit at Bottom Navigation Bar.在我的应用程序中有底部导航栏,我想添加导航抽屉,因为有许多按钮不适合底部导航栏。 i tried many ways but unfortunately none of them worked here is my Bottom Navigation Bar xml code我尝试了很多方法,但不幸的是没有一个在这里工作是我的底部导航栏 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"
    android:background="@color/colorAccent2"
    tools:context=".UI.HomeActivity"
    tools:layout_editor_absoluteY="81dp">



    <FrameLayout

        android:id="@+id/frame1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="5dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="0dp"
        app:layout_constraintBottom_toTopOf="@+id/navigationView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="spread_inside">

    </FrameLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigationView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#fcff38"
        app:itemIconTint="#000000"
        app:itemTextColor="#303132"

        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/frame1"
        app:menu="@menu/menu" />


</androidx.constraintlayout.widget.ConstraintLayout>

Any answer could help, Thanks.任何答案都可以帮助,谢谢。

You need to add 'NavigationView' class in the layout, also wrap the root view group inside DrawerLayout.您需要在布局中添加“NavigationView”类,并将根视图组包装在 DrawerLayout 中。

<androidx.drawerlayout.widget.DrawerLayout>

  <androidx.constraintlayout.widget.ConstraintLayout>

    <FrameLayout
    ...
    </FrameLayout>

  <com.google.android.material.bottomnavigation.BottomNavigationView/>

  </androidx.constraintlayout.widget.ConstraintLayout>

  <com.google.android.material.navigation.NavigationView />

</androidx.drawerlayout.widget.DrawerLayout>

This post will help you:NavigationView这篇文章将帮助你:NavigationView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM