Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 添加带底部导航栏的导航抽屉_Android - Fatal编程技术网

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

Android 添加带底部导航栏的导航抽屉,android,Android,在我的应用程序中有底部导航栏,我想添加导航抽屉,因为底部导航栏上有许多按钮不适合。 我尝试了很多方法,但不幸的是没有一种有效 下面是我的底部导航条xml代码 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app

在我的应用程序中有底部导航栏,我想添加导航抽屉,因为底部导航栏上有许多按钮不适合。 我尝试了很多方法,但不幸的是没有一种有效 下面是我的底部导航条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>

任何答案都有帮助,
谢谢。

您需要在布局中添加“NavigationView”类,还需要将根视图组包装在抽屉布局中

<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>