I have a RelativeLayout
which contains a ListView
.
When I scroll the listview up and down, I experience this on the RelativeLayout's onInterceptTouchEvent()
:
ACTION_DOWN
is fired ACTION_MOVE
are fired ACTION_UP
is never fired Please note:
Can anyone give an explanation for this?
===
This is the simple layout I am using:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@+id/listview"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
If I understand correctly, you want the RelativeLayout to receive the ACTION_UP event. A viewgroup (RelativeLayout) won't receive future touch events unless it expresses interest in the first touch events by returning true - so you should return true from onInterceptTouchEvent, not false.
Dave Smith explains it well here: http://www.doubleencore.com/2014/01/dave-smiths-talk-from-andevcon-2013-android-touch/
Summary: Return true, not false. And watch that video for a much better explanation :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.