0
我有一个NestedScrollView之上的RelativeLayout。我想阻止任何对RelativeLayout的点击传播,但允许所有的滚动事件。 应适用于RelativeLayout的与“controllers_container” ID如何防止点击事件和绕过视图上的滚动事件?
<android.support.design.widget.CoordinatorLayout
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">
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
... content ...
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchor="@id/scrollView"
app:layout_anchorGravity="bottom|left|end">
<RelativeLayout
android:id="@+id/controllers_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_vertical_margin"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/bottom_bar">
... content ...
</RelativeLayout>
... content ...
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
添加android:clickable="true"
防止任何触摸事件,包括滚动。我试图设置一个触摸侦听器的scrollView,但不能按需要管理它。有任何想法吗?
尝试将触摸事件切换到父级布局,并使用onTouchIntercept进行处理 – Vicky