AppCompat 导航抽屉不让我关注任何 EditText

AppCompat Navigation Drawer not letting me to focus any EditText

我正在使用 AppCompat 支持库为 pre-L(恰好 API 9+)设备创建应用程序。 我遇到的问题与 AppCompat 的导航抽屉有关:如果我的布局中有一个抽屉并且我正在初始化它,我的片段中的 none EditText elemenets 无法聚焦(它们正在瞬间获得焦点,然后他们丢失了它;软键盘没有显示)。

我只使用 activity 来加载片段:

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:foreground="?android:windowContentOverlay">

        <View
            android:layout_width="match_parent"
            android:layout_height="4dp"
            android:background="@drawable/toolbar_shadow"/>

        <FrameLayout
            android:id="@+id/app_fragment"
            android:layout_below="@id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/scan_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_margin="16dp"
            android:clickable="true"
            android:src="@drawable/ic_scan"
            app:borderWidth="0dp"
            app:elevation="4dp"/>

    </RelativeLayout>

</LinearLayout>

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

我在没有初始化抽屉的情况下测试了代码,一切正常。知道是什么导致了这个问题吗?

所以我找到了问题所在。我不知道为什么,可能是因为触摸事件是通过抽屉进行的,我的代码中有这一行禁用了 DrawerLayout 下所有内容的任何事件:

    drawer.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);