Android滑动手势不适用于儿童视图 [英] Android swipe gesture not working for child views

查看:68
本文介绍了Android滑动手势不适用于儿童视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有一些可单击视图的布局. 我已经按照实现了滑动手势. 如果您在空白区域内滑动,则效果很好,但如果开始在布局内的一个视图内滑动,则此方法将不起作用.

I have a layout with some clickable views in it. I have implemented swipe gesture as per this. This is working great if you swipe in an empty area, but it does not work if you start swiping inside one of the views inside the layout.

如何避免这种情况?向活动中的单个视图添加onSwipeListener似乎很疯狂.有更好的方法吗?

How can this be avoided? Adding onSwipeListener to ever single view in the activity seems insane. Is there a better way?

推荐答案

在子视图中设置android:clickable=false.这样可以防止他们拦截来自父级的触摸事件.

Set android:clickable=false in your child views. This will prevent them from intercepting the touch events from the parent.

这篇关于Android滑动手势不适用于儿童视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆