【问题标题】:How to make the second navigation drawer NOT cover the app bar?如何使第二个导航抽屉不覆盖应用栏?
【发布时间】:2015-10-10 08:48:54
【问题描述】:

我一直在处理这个 DrawerLayout 和 NavigationViews,但我似乎无法解决这个问题。根据谷歌指南,第一个导航栏应该覆盖应用栏,第二个不应该。

我如何做到这一点?无论我做什么,要么让它们都覆盖,要么它们都没有覆盖应用栏。

由于导航视图相当新,我无法通过谷歌搜索和探索overflow.com 获得任何合适的答案。非常感谢任何指南、帮助、教程、示例...。

之前谢谢。

这是我的activity.xml

<android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <LinearLayout
            android:orientation="vertical"
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
        <include
                android:id="@+id/app_bar"
                layout="@layout/app_bar">
        </include>
    </LinearLayout>


    <android.support.design.widget.NavigationView
            android:id="@+id/nav_draw"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/drawer_header"
            app:menu="@menu/drawer"/>
    <android.support.design.widget.NavigationView
            android:id="@+id/second_nav_draw"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="end"
            />
</android.support.v4.widget.DrawerLayout>

【问题讨论】:

    标签: android navigation-drawer material-design android-design-library android-navigationview


    【解决方案1】:

    我不了解 NavigationView,但对于其他视图来说,一个简单的边距可以正常工作。试试:

    android:layout_marginTop="?attr/actionBarSize"
    

    【讨论】:

    • 谢谢。有效。只有 actionBarHeight 应该替换为 actionBarSize 因为它给出了未找到的错误。
    • 是的,对不起,我没有先检查就写了。
    猜你喜欢
    • 2014-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    相关资源
    最近更新 更多