0

我花了很多时间试图找出问题ActionBarDrawerToggle所在,但问题出在我的主布局中。

让我展示一下问题所在。

这是示例,它在应用程序启动后最初的样子。

在此处输入图像描述

如您所见,汉堡包存在,但现在未显示。
比起滑动抽屉菜单,它会出现。

在此处输入图像描述

它看起来应该看起来像,但它可能会突然消失,例如invalidateOptionsMenu()在被调用时。

所以我试图找到切换的问题,但它在我的布局中

这是我的布局 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"
    android:id="@+id/navigation_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/linear_layout_main_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar_main"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                android:visibility="gone"
                app:theme="@style/MainAppTheme.ToolbarMain"
                app:titleTextAppearance="@style/MainAppTheme.Toolbar.Title" />
        </LinearLayout>

        <ViewStub
            android:id="@+id/stub_progress_bar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inflatedId="@+id/progress_bar_buttons"
            android:layout="@layout/view_stub_progressbar_bg" />
    </FrameLayout>

    <ScrollView
        android:id="@+id/frame_layout_drawer_left"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fillViewport="true">

    </ScrollView>

    <ScrollView
        android:id="@+id/frame_layout_drawer_right"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:fillViewport="true" />
</android.support.v4.widget.DrawerLayout>

问题出在最后一个ScrollView,没有最后/右滚动视图一切正常。顺便说一下,这种布局与两个抽屉配合得很好,但在这种情况下只漏掉了汉堡包。
我想问题是导航抽屉工具与两个导航抽屉视图冲突。
因为重力端的视图类型无关紧要,在这种情况下它不会显示汉堡包(如果存在重力端的视图)

请帮忙解决这个问题,因为我不知道如何处理它,反正我需要两个抽屉。

任何帮助将不胜感激,谢谢。

4

1 回答 1

1

这是一个非常有趣的问题,但我想我有一个解决方案。那么2个解决方案,

  1. 您是否创建了一个Frame Layout包含两个独立 布局的android.support.v4.widget.DrawerLayout布局?

    <FrameLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.v4.widget.DrawerLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <!--your content -->
            <ScrollView
                android:id="@+id/frame_layout_drawer_left"
                android:layout_width="0dp"
                android:layout_height="match_parent"/>
        </android.support.v4.widget.DrawerLayout>
    
        <android.support.v4.widget.DrawerLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <ScrollView
                android:id="@+id/frame_layout_drawer_right"
                android:layout_width="0dp"
                android:layout_height="match_parent"/>
        </android.support.v4.widget.DrawerLayout>
    </FrameLayout>
    
  2. 将第二个抽屉布局嵌入到根目录 android.support.v4.widget.DrawerLayout中。

示例 xml

<android.support.v4.widget.DrawerLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!--your content -->
    <ScrollView
        android:id="@+id/frame_layout_drawer_left"
        android:layout_width="0dp"
        android:layout_height="match_parent"/>

    <android.support.v4.widget.DrawerLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:id="@+id/frame_layout_drawer_right"
            android:layout_width="0dp"
            android:layout_height="match_parent"/>
    </android.support.v4.widget.DrawerLayout>

</android.support.v4.widget.DrawerLayout>
于 2015-09-15T19:26:12.997 回答