我的导航抽屉一直显示在全屏,无法滑动[关闭] 。

问题描述 投票:0回答:1

我创建了一个导航抽屉,但它一直显示在全屏上.无法滑动它.我怎么能解决这个问题?

这是我的代码,请帮我解决这个问题。

 <?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.android.navigationpanal.MainActivity"
    tools:openDrawer="start">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

    <com.google.android.material.navigation.NavigationView **i use this tag**
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/navigation_menu"
        android:fitsSystemWindows="true"
        android:layout_gravity="start"/>
</androidx.drawerlayout.widget.DrawerLayout>

我尝试了所有的解决方案,但都是徒劳的,请你能帮助我解决这个问题。我已经创建了单独的头文件和导航菜单文件。

android xml android-layout navigation-drawer
1个回答
1
投票

试着将其从 NavigtionView

android:fitsSystemWindows = "true"

这将使你的NavigationView布局适合android系统窗口。

© www.soinside.com 2019 - 2024. All rights reserved.