简体   繁体   English

导航抽屉不够宽

[英]Navigation drawer not wide enough

How can I make my navigation drawer as wide as what is suggested (like in the Gmail app)? 如何使导航抽屉达到建议的宽度(例如Gmail应用程序中的宽度)?

在此处输入图片说明

In my app it only extends to just over half of the screen. 在我的应用中,它仅扩展到屏幕的一半以上。

activity_main.xml activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context="com.example.apple.bookshelf.MainActivity">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"  />

        </android.support.design.widget.AppBarLayout>

        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/authors_list_view"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <include layout="@layout/content_main" />

    </android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/menu_navigation"/>

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

Possibly you could try to customize the Navigation drawer. 可能您可以尝试自定义导航抽屉。 The official documentation says 官方文件说

If none of the prebuilt widgets or layouts meets your needs, you can create your own View subclass. 如果没有预构建的小部件或布局满足您的需求,则可以创建自己的View子类。

you could think to create your own Navigation Drawer, here are offered several solutions, also the possibility to use libraries, you can see the source code, but also trying in the classical way, extending the class you need and override the methods you want to change 您可能会想到创建自己的导航抽屉,这里提供了几种解决方案,还提供了使用库的可能性,您可以看到源代码,还可以尝试以经典方式扩展所需的类并覆盖所需的方法。更改

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

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