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