我有一個類似的佈局:傳遞觸摸事件滾動型的家長
<FrameLayout>
<ScrollView>
<RelativeLayout>
</RelativeLayout>
</ScrollView>
</FrameLayout>
我想滾動型與垂直手勢(滾動/一扔)正常工作,並通過水平姿態到它的父(FrameLayout裏有拖動功能並沒有ScrollView工作正常)。
我有一個類似的佈局:傳遞觸摸事件滾動型的家長
<FrameLayout>
<ScrollView>
<RelativeLayout>
</RelativeLayout>
</ScrollView>
</FrameLayout>
我想滾動型與垂直手勢(滾動/一扔)正常工作,並通過水平姿態到它的父(FrameLayout裏有拖動功能並沒有ScrollView工作正常)。
您需要創建一個新的類擴展FrameLayout和ovverriding onInterceptTouchEvents
比你可以執行你的邏輯,並決定哪些事件必須發送到scrollview和哪些必須在FrameLayout內處理onTouchEvent
您可以查看官方文檔here
您可以嘗試覆蓋onInterceptTouchEvent()將觸摸事件傳遞給其父視圖。爲了您的參考,請通過此鏈接https://developer.android.com/training/gestures/viewgroup.html