滑动多视图

问题描述 投票:0回答:1

我试着像在游戏Word Connect中那样听动作。他们可以听动作滑动多个视图,如图:它来自H - > O - > N.我可以听一个单一视图的动作:onClick,onTouch,..但有多个视图,我不能。我怎样才能做到这一点?提前致谢。 A picture of WordConnect

android ontouchlistener ontouchevent
1个回答
0
投票

在viewGroup中组织所需的视图并启用以下属性:

ViewGroup.setMotionEventSplittingEnabled(true);

或者在layout.xml中添加android:splitMotionEvents=“true”。然后将onTouch侦听器设置为所有视图,并为每个视图添加代码。上面的属性将触发用户触摸的每个视图的触摸事件。

© www.soinside.com 2019 - 2024. All rights reserved.