Android 重叠视图和处理点击

Android Overlapping views and handle clicks

所以我有这个 activity 布局:

<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_layout"
    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">
            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/AppTheme.AppBarOverlay">

                <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/AppTheme.PopupOverlay" />
            </android.support.design.widget.AppBarLayout>
    </android.support.design.widget.CoordinatorLayout>

    <FrameLayout
        android:id="@+id/mainContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <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:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

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

我的 mainContent 是碎片会夸大其观点的地方。在我的特殊情况下,膨胀的片段将具有卡片视图的回收视图。

问题是,事实上,布局看起来像我想要的那样:

但是抽屉式导航图标无法点击。如果我将协调器布局与框架布局交换,会发生这种情况:

并且导航抽屉变得可点击但图标被切断。我知道我在这里遗漏了一些东西,我只是想不通。 我试图将两者都放在框架布局中,但输出相同。

那个按钮不应该 there.That 不是 MaterialDesign 指南所说的。

您可以将 FloatingActionaButton 与如下样式一起使用: https://github.com/xuyisheng/DesignSupportLibraryDemo

或者像下面这样使用:

<android.support.design.widget.FloatingActionButton
    android:onClick="checkin"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    android:clickable="true"
    android:src="@drawable/ic_discuss"
    app:layout_anchor="@id/appbar"
    app:layout_anchorGravity="bottom|right|end"/>

https://github.com/xuyisheng/DesignSupportLibraryDemo/blob/master/app/src/main/res/layout/activity_detail.xml

关于那个 FrameLayout,正如我所见,你有 CoordinatorLayout 那个 FrameLayout 我认为我们认识的 FrameLayout 就像 NavigationDrawer.

尝试在某处使用它else.or使用下面的答案: