显示 DrawerLayout 时 Android View 可点击

标签 android navigation-drawer

在我的应用程序中,当我打开 view 下方的 DrawerLayout 是可点击的时,我厌倦了阅读这个问题并尝试修复,但我做不到,我的 DrawerLayout 必须作为中间 View 和菜单项的父级。

这是xml布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical">

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

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@android:color/transparent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/simcard_lists"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingBottom="5dp"
                android:paddingTop="5dp"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/slide_menu"
            android:layout_width="250dp"
            android:layout_height="fill_parent"
            android:layout_gravity="right"
            android:background="#ffffff"
            android:dividerHeight="0dp"
            android:orientation="vertical"
            android:paddingRight="10dp">

            <LinearLayout
                android:id="@+id/filter_simcards"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_marginTop="20dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginRight="10dp"
                    android:layout_weight="1"
                    android:paddingRight="15dp"
                    android:text="@string/filter_by_simcard_code"
                    android:textSize="15sp"/>

                <com.joanzapata.iconify.widget.IconTextView
                    android:layout_width="30dp"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:clickable="true"
                    android:gravity="center"
                    android:shadowColor="#22000000"
                    android:shadowDx="3"
                    android:shadowDy="3"
                    android:shadowRadius="1"
                    android:text="{fa-filter}"
                    android:textColor="#9f24b8"
                    android:textIsSelectable="false"
                    android:textSize="30sp"/>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/my_buys_lists"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center|right"
                android:orientation="horizontal">

                <com.joanzapata.iconify.widget.IconTextView
                    android:layout_width="30dp"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:clickable="true"
                    android:gravity="center"
                    android:shadowColor="#22000000"
                    android:shadowDx="3"
                    android:shadowDy="3"
                    android:shadowRadius="1"
                    android:text="{fa-check}"
                    android:textColor="#9f24b8"
                    android:textIsSelectable="false"
                    android:textSize="30sp"/>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/about_us"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">

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

这意味着 recyclerview 项目在显示 DrawerLayout 时可点击

最佳答案

将android:clickable="true"放在代表抽屉的布局中。android:layout_gravity="start"的布局

关于显示 DrawerLayout 时 Android View 可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39483321/

相关文章:

Android App Bundle(仅限) - 无法加载原生库

android - fragment 中不合适的上下文菜单

android drawerlayout with actionbarsherlock

android - DrawerLayout:抽屉打开时禁止点击内容

java - 如何使用共享首选项将媒体静音

java - 有谁知道如何修复此构建工具版本错误?

android - 如何在 Google 登录后禁用转换?

android - 使用 Apache POI 打开 .xlsx 文件时出现异常

android - 更改抽屉导航图标的大小

java - 在 Fragment 中带有图像和文本的 Android ListView