我有一个DrawerLayout,里面有一个EditText和一个ListView.
问题是,我无法触摸我的EditText或ListView项目.而不是它
DrawerLayout接收所有触摸事件.单击DrawerLayout中的任何项目会导致DrawerLayout关闭(我猜这是drawerlayout类中的默认onTouch方法)
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background" >
android:id="@+id/left_linear"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:clickable="true"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="true"
android:orientation="horizontal" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/noborder"
android:clickable="true"
android:hint="search box 1"
android:padding="8dp"
android:singleLine="true" />
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="5dp"
android:src="@android:drawable/ic_menu_search" />
android:id="@+id/left_drawer"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
解决方法:
在你的oncreate中尝试drawerlayout.requestDisallowInterceptTouchEvent(true)
标签:android,drawerlayout
来源: https://codeday.me/bug/20190528/1174578.html
本文介绍了一个关于DrawerLayout接管所有触摸事件,导致EditText和ListView无法响应点击的问题。作者提供了在onCreate中使用drawerlayout.requestDisallowInterceptTouchEvent(true)的方法来解决此问题,适用于Android开发者。

955

被折叠的 条评论
为什么被折叠?



