web-dev-qa-db-fra.com

Tiroir de navigation plein écran

J'ai un tiroir de navigation comme this .

Ce que je veux faire, c’est ouvrir mon tiroir au plein écran et non à la moitié de l’écran …….

C'est xml of tiroirlayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:fitsSystemWindows="true">

<include
    Android:id="@+id/toolbar_layout"
    layout="@layout/app_toolbar"
    Android:layout_width="match_parent"
    Android:layout_height="wrap_content" />

<Android.support.v4.widget.DrawerLayout
    Android:id="@+id/drawer_layout"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent"
    Android:layout_below="@id/toolbar_layout"
    Android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <FrameLayout
        Android:id="@+id/activityMainContent"
        Android:layout_width="match_parent"
        Android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <Android.support.design.widget.NavigationView
        Android:id="@+id/nav_view"
        Android:layout_width="wrap_content"
        Android:layout_height="match_parent"
        Android:layout_gravity="start"
        Android:background="@color/colorPrimary"
        Android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:itemTextColor="@Android:color/white"
        app:menu="@menu/activity_main_drawer" />
</Android.support.v4.widget.DrawerLayout>
</RelativeLayout>
7
Shrikant

Vous pouvez essayer cecinavigationViewproperty 100% work

<Android.support.design.widget.NavigationView
    Android:id="@+id/nav_view"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent"
    Android:layout_gravity="start"
    Android:fitsSystemWindows="true"
    Android:layout_marginEnd="-65dp"
    Android:layout_marginRight="-65dp"
    app:itemTextColor="@color/lightgray"
    app:itemIconTint="@color/colorAccent"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer" />
18
Ratilal Chopda

essayez cet espoir que cela fonctionne:

<include
        Android:id="@+id/left_drawer"
        Android:orientation="vertical"
        Android:layout_width="match_parent"
        Android:layout_height="match_parent"
        Android:layout_gravity="start"
        layout="@layout/drawer"
        Android:layout_marginLeft="-64dp"/>
1
Apoorv Mehrotra

Vous devez mettre votre DrawerLayout comme disposition principale dans votre xml comme ceci:

<?xml version="1.0" encoding="utf-8"?>
<Android.support.v4.widget.DrawerLayout
    Android:id="@+id/drawer_layout"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent"
    Android:layout_below="@id/toolbar_layout"
    Android:fitsSystemWindows="true"
    tools:openDrawer="start">

<RelativeLayout 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:fitsSystemWindows="true">

<include
    Android:id="@+id/toolbar_layout"
    layout="@layout/app_toolbar"
    Android:layout_width="match_parent"
    Android:layout_height="wrap_content" />

    <FrameLayout
        Android:id="@+id/activityMainContent"
        Android:layout_width="match_parent"
        Android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <Android.support.design.widget.NavigationView
        Android:id="@+id/nav_view"
        Android:layout_width="wrap_content"
        Android:layout_height="match_parent"
        Android:layout_gravity="start"
        Android:background="@color/colorPrimary"
        Android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:itemTextColor="@Android:color/white"
        app:menu="@menu/activity_main_drawer" />

</RelativeLayout>

</Android.support.v4.widget.DrawerLayout>