I asked a similar question before but the answer was not very helpful and I can't find any solution for this problem.
I want to know a method to detect ACTION_DOWN when we only touch a certain view and to detect ACTION_MOVE when we only move our finger on screen, because all I am getting is ACTION_DOWN and ACTION_MOVE being called at the same time when I place my finger on the view.
can anyone please post a simple code for how to do that.
That are raw motion events. You can probably use GestureDetector and detect click and swipe.
Problem is that ACTION_MOVE will be called when any move is detected, for example applying just a little more pressure when touching screen might move touch point few pixels around.
Related
What is the difference between onScroll() and onFling() in the GestureDetector interface?
When I print out the events they are showing the exact same things. At least the last onScroll() and the onFling().
The only true difference I noticed is that onScroll() is called much more often, fling always just one time.
The difference between Scroll and fling
onFling: is that the user lifts his finger in the end of the movement (that is the reason for what onFling is called one time).
onScroll: is the general process of moving the viewport (that is, the 'window' of content you're looking at).
Understand Scrolling Terminology "Scrolling" is a word that can take on different meanings in Android, depending on the context.
Scrolling is the general process of moving the viewport (that is, the
'window' of content you're looking at). When scrolling is in both the
x and y axes, it's called panning. The sample application provided
with this class, InteractiveChart, illustrates two different types of
scrolling, dragging and flinging:
Dragging is the type of scrolling that occurs when a user drags her
finger across the touch screen. Simple dragging is often implemented
by overriding onScroll() in GestureDetector.OnGestureListener. For
more discussion of dragging, see Dragging and Scaling.
Flinging is the type of scrolling that occurs when a user drags and lifts her finger
quickly. After the user lifts her finger, you generally want to keep
scrolling (moving the viewport), but decelerate until the viewport
stops moving. Flinging can be implemented by overriding onFling() in
GestureDetector.OnGestureListener, and by using a scroller object.
I am creating an Android game that uses touch input. I noticed that, when I put down a finger and move it, there is a threshold of a couple of pixels until the first MotionEvent.ACTION_MOVE is generated. What is the correct way of disabling this threshold filter?
It's called touch slop. And here's the same question already answered: Android ACTION_MOVE Threshold
So basically I made the screen with 2 paddles and a very simple score board. I've been researching a little and found the onTouch method. But that only works for 1 paddle. How about 2 player? Is there a onTouch and drag method, because I want the player to touch the paddle and move it right or left. And lastly how can I do that for both of the paddles?
Thanks in advance.
Read more here. onTouchEvent receives MotionEvent object, and you can handle multiple touches using event.getActionIndex() and event.getPointerId(). You should probably determine if you're moving tob or bottom paddle by initial touch coordinates, and then handle events properly (by moving paddle that matches PointerId for example)
I am testing this sample on version 13 of android (3.2) and I have an issue when there is multiple touches on screen.
When I first touch, then there is an action_down event, if I make another simultaneous touch, then I won't get another action_down, my first touch keeps active and I can keep getting action_move from the first touch.
The problem is, when I release the first touch and move the second, it creates a line to that touch, because it generates another action_move event.
I tried using Euclidean distance, but it seems to slow down too much, and makes the lines incomplete.
I tried creating a producer/consumer model, but still got the same problem.
I also tried checking the time from the last touch, but this is very inefficient.
Does anyone have any suggestion?
I admit I'm a little confused about what your actual problem is, but it seems to me like your problem might be solved simply by handling more of the touch events. When the second finger comes down, you can get an ACTION_POINTER_DOWN event, indicating a second touch, and you can then modify how your ACTION_MOVE events will be interpreted while the second finger is down, until an ACTION_POINTER_UP event comes through. Hope that answers or at least helps your question.
I am developing an Android application. I am novice in Touch enabled Android Application. I have read the article about onFling and onScroll events on:
http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html
But I didn't get exactly what is the meaning and for what we can use onFling and onScroll events.
onScroll event is when user touches down the screen, moves finger in some direction and lift up. It is mostly used to scroll larger layouts over a smaller viewport. onFling is the same, but made faster and usually triggers an animation that keeps scrolling few moments more after finger lifted up.