防止父布局消耗可缩放图像视图的触摸事件

Prevent parent layout from consuming the touch event of an Zoomable image view

我有一个 CustomeLinearlayout,允许从下到上或从上到下滑动以隐藏自身。在此布局中,我有一个可缩放的自定义图像视图,问题是当我在图像视图上自上而下、自下而上滑动时,布局获取触摸事件。我知道为什么会发生这种情况,但找不到阻止它的方法。

自定义linearlayout的onInterceptTouchEvent()方法中的代码

....
case MotionEvent.ACTION_MOVE:
     // check if user swipe top-bottom or bottom-top
     // return true if it is, break otherwise
     // The current implementation always return true if it detects user is swiping from top to bottom or bottom to top (doesnt care how its children feel)
....

我的问题是如何检测用户是否想要滚动缩放图像而不是滑动线性布局?。仅当缩放图像未缩放(缩放比例为 1f)时,Layout 才处理其 onTouch

如果你的图片被放大了那么你可以调用requestDisallowInterceptTouchEvent(true)方法