Questions tagged [motionevent]

MotionEvent object used to report movement (mouse, pen, finger, trackball) events. Motion events may hold either absolute or relative movements and other data, depending on the type of device. Motion events describe movements in terms of an action code and a set of axis values. The action code specifies the state change that occurred such as a pointer going down or up. The axis values describe the position and other movement properties.

468 questions
49
votes
2 answers

In Android, what is the difference between getAction() and getActionMasked() in MotionEvent?

I am confused by the two methods in Android. It seems that both methods tell you what kind of event it is, i.e., whether it is a down or up event. When will I use which? public void onTouchEvent(MotionEvent e) Don't quote the documentation please,…
user1233587
  • 2,033
  • 4
  • 24
  • 24
46
votes
5 answers

What causes a MotionEvent.ACTION_CANCEL in Android?

I am working through debugging some touch handling stuff on Android, and am trying to figure out why the MotionEvent sent to my View's onTouchListener contains a cancel action. I have not been able to find any documentation on its cause, and was…
Phil
  • 35,852
  • 23
  • 123
  • 164
16
votes
1 answer

The difference of using MotionEvent.getAction() method

What is the difference between the two approaches below? int action1 = event.getAction() & MotionEvent.ACTION_MASK; int action2 = event.getAction();
iCould7
  • 635
  • 6
  • 10
15
votes
2 answers

What's the difference between ACTION_CANCEL and ACTION_UP in MotionEvent?

I want to track a finger touch on the screen. So what I did was to start recording the position when MotionEvent triggers ACTION_DOWN, but how do I know when the action is finished, at ACTION_CANCEL, or ACTION_UP? What's the exact difference between…
James
  • 5,119
  • 5
  • 25
  • 27
12
votes
2 answers

How to change view's size from 4 side in Android?

Is it possible to resize by pulling the matrix on the 4 side of the view? I can resize from a single point to a ratio like this. The example above works as follows: protected boolean onTouchDown(@NonNull MotionEvent event) { oldDistance = (float)…
Umut ADALI
  • 1,146
  • 1
  • 14
  • 31
12
votes
1 answer

Android - Detect Touch Pressure on capacitive touch screen?

I've heard of: MotionEvent e; float press = e.getPressure(...); But this only returns 0 for no touch, and 1 when my finger touches the screen. Is it possible to find a value for the amount of pressure your finger is putting on the screen with touch…
Loren Kuich
  • 573
  • 3
  • 10
  • 25
10
votes
3 answers

How to find the source view of a MotionEvent ACTION_CANCEL

How can I find the view causing a MotionEvent ACTION_CANCEL? I have a view "A" which is receiving ACTION_CANCEL and I don't want that to happen. Somewhere, a view "B" is "consuming" the MotionEvent. I'm hoping there is a way to find out who is…
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
10
votes
6 answers

WebView getting rid of double tap zoom.

I read many tickets on the topic of Zooming in WebViews and didnt came to an answer for my case. Here´s my setup: I´m using a custom webview with generally these settings:…
Ostkontentitan
  • 6,930
  • 5
  • 53
  • 71
9
votes
3 answers

Pass motion event to parent Scrollview when Listview at top/bottom

I have a ListView in a ScrollView to show comments and I would like to do the following: When the user swipes down, first the ScrollView should fully scroll down as the list is at the bottom. Once it's fully down, the Listiew should start…
Gooey
  • 4,740
  • 10
  • 42
  • 76
9
votes
1 answer

onInterceptTouchEvent never receives action_move

I have a custom ViewGroup with an override of onInterceptTouchEvent(). It receives ACTION_DOWN but never receives ACTION_MOVE. It is my understanding that, unless it returns "true", it should receive all MotionEvents. The ViewGroup contains two…
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
8
votes
1 answer

Android MotionEvent Pointer Index Confusion

I have a problem with my Android app that requires touch tracking events (tracking when/where finger goes down, move, up, etc). I have to use event.getX() and event.getY() functions to get the current touch's coordinates. So from what I've learned…
yun
  • 1,243
  • 11
  • 30
7
votes
2 answers

JS use DeviceAcceleration.x to pan image seamlessly

I have an image larger than viewport that I'm trying to pan on the x plan according to device Acceleration value. _____________________ | | | Device | | …
kursus
  • 1,396
  • 3
  • 19
  • 35
7
votes
1 answer

Find out which View consumed touch event, if any

I was troubleshooting a view-related issue: a click listener that is not fired when it's supposed to. After a long session of trial-and-error, I found out that a parent view was disabled, thus discarding all events to its children. Is there a way,…
7
votes
1 answer

Registering UP/CANCEL from Dialog when DOWN event was triggered from a View's LongPress

I have a UX requirement that the user triggers a Dialog by long pressing a cell in a GridView. While the Dialog is displayed the user must be able to move their finger/thumb around the screen without triggering the UP/CANCEL event when they leave…
Bill Mote
  • 12,644
  • 7
  • 58
  • 82
7
votes
0 answers

Simulate a mouse input on android

Imagine that I have a service that receives coordinates from a bluetooth device, now I want to display a mouse cursor whenever it moves. I managed to send MotionEvents with a toolType = TOOL_TYPE_MOUSE but I don't get the native android mouse cursor…
Fernando Gallego
  • 4,064
  • 31
  • 50
1
2 3
31 32