Android DrawerLayout和NavigationView未完全展开

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

[嗨,我已经构建了一个带有NavigationView和工具栏的DrawerLayout。问题在于,NavigationView不能完全如图所示那样展开。我尝试使用android:fitsSystemWindows = true和false,但没有一个起作用。enter image description here

这是我在布局文件中的代码。

    <?xml version="1.0" encoding="utf-8"?>
<layout 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"
    tools:context=".view.MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <FrameLayout
            android:id="@+id/frame_sceneform_fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <fragment
                android:id="@+id/sceneform_fragment"
                android:name="com.google.ar.sceneform.ux.ArFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </FrameLayout>


        <FrameLayout
            android:id="@+id/frame_menu_nav_host"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="100dp"
            android:background="#FFFFFF"
            android:visibility="invisible"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">
            <androidx.drawerlayout.widget.DrawerLayout
                android:id="@+id/drawer_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <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"
                        />

                    <fragment
                        android:id="@+id/fragment_menu_nav_host"
             android:name="androidx.navigation.fragment.NavHostFragment"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:defaultNavHost="true"
                        app:navGraph="@navigation/menu_navigation" />
                </LinearLayout>
                <com.google.android.material.navigation.NavigationView
                    android:id="@+id/nav_view"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="start"
                    app:menu="@menu/hamburger_menu"/>
            </androidx.drawerlayout.widget.DrawerLayout>

        </FrameLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

我想删除状态栏通常位于的灰色区域以及底部为移动设备上的操作按钮指定的灰色区域。这可能吗,还是我必须做一个定制设计?

android android-layout navigation-drawer drawerlayout navigationview
1个回答
0
投票

像这样在style.xml文件夹中放入新样式;

    <style name="AppTheme.NoActionBar" >
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

并在清单文件中定义它;

<activity android:name=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
© www.soinside.com 2019 - 2024. All rights reserved.