滑动手指在屏幕上的按钮激活,好像他们是pressed [英] Sliding finger across screen activating buttons as if they were pressed
问题描述
在我的情况下,标题是不够清楚,我会详细解释一下:
In case my title wasn't clear enough, I'll explain it in detail:
假设我们有充满了多个按钮(10+)的屏幕,我们preSS跪下一条,激活onTouch /的onClick。如果我们现在移动手指,没有提起,我想它来激活其他任何按钮,它滑过。在这种特殊情况下,我想,当你滑过一个虚拟的钢琴音色进行播放。
Say we have a screen filled with multiple buttons (10+), and we press down on one, activating onTouch/onClick. If we now move the finger, without lifting it, I want it to activate any other button it slides over. In this particular case, I want sound to be played when you slide over a virtual piano.
我知道你在哪里注册的每个ACTION_MOVE并找到了一些界限,激活新事件onTouchListener的解决方案,但是从优化远远如果你有多个按钮,并想让流畅无延迟滑动。
I know about the onTouchListener-solution where you register every ACTION_MOVE and find some boundaries that activates new events, but that's far from optimal if you have multiple buttons and want to allow smooth sliding without delay.
我也读<一个href=\"http://stackoverflow.com/questions/4838609/detect-which-view-your-finger-is-sliding-over-in-android\">this螺纹这表明,我们结合观的touchListener从活动gesturelistener,但再次,这并不在所有最适合我的处境感觉。
I also read this thread which suggested that we combine the touchListener of the View with a gesturelistener from the activity, but once again, this does not feel at all optimal for my situation.
我没有试过结合touchlistener与gesturelistener,但我会继续前进,这样做,如果有人告诉我,他们有这样做的没有其他办法。
I have not tried combining touchlistener with gesturelistener yet, but I will go ahead and do so if someone tells me they have no other way of doing this.
推荐答案
我居然把易的出路,并使用使用的按钮与onTouch法 ACTION_DOWN
和 ACTION_MOVE
与协调与 event.getX()组合计算
和 event.getY()
让我来检测哪个按钮目前徘徊。它是免费的滞后与13个按钮。
I actually took the "easy" way out and used buttons with an onTouch-method using ACTION_DOWN
and ACTION_MOVE
with coordinate calculations that combined with event.getX()
and event.getY()
allows me to detect which button is currently hovered. It's lag free with 13 buttons.
这篇关于滑动手指在屏幕上的按钮激活,好像他们是pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!