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
7
votes
4 answers

Get button coordinates and detect if finger is over them - Android

I have 4 buttons in my android app activity. This is what it looks like: As you can see, the textViews at the bottom of the screen display the x and y coordinates. The coordinates are in reference to a relative layout. (See below given code) Now,…
Chinmay Dabke
  • 5,070
  • 11
  • 40
  • 63
7
votes
2 answers

MotionEvent.ACTION_CANCEL is not triggered during onTouch

I am having this problem where ACTION_CANCEL is not triggered, I have implemented it in my other project and it's working fine. It seems that ACTION_UP is the only MotionEvent that is called after ACTION_DOWN. I wanted to trigger ACTION_CANCEL once…
Compaq LE2202x
  • 2,030
  • 9
  • 45
  • 62
7
votes
2 answers

Android inject touch event

I know this is a bit repeating question. I have reviewed various questions on SO and few other sites but could not find a single answer that satisfies my need. Requirement 1) I have X,Y coordinates, I want to create MotionEvent and dispatch it to…
TorukMakto
  • 2,066
  • 2
  • 24
  • 38
7
votes
2 answers

Syncing Two ListViews side by side Android

I'm trying to make two side by side ListViews act like a GridView to an extent. The reason I'm not using GridView is because there's no support for a Staggered Look. Anyways, I have the following code so far: <- Old,now irrelevant code -> EDIT: I…
Kgrover
  • 2,106
  • 2
  • 36
  • 54
7
votes
4 answers

onInterceptTouchEvent, onTouchEvent only see ACTION_DOWN

I have a top level ViewGroup, which I call SliderView, in which I want to detect swiping. This is mostly working, but one weird failure persists. The essence of SliderView is to override onInterceptTouchEvent and, once the user is actually swiping,…
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
6
votes
2 answers

Invisible views detection on motion event

As i already tried views with motion drag reading Android docs. I have clearly not saying about basics of it but i want to hide orinvisible view which will be visible when other view which is being dragged or using motion can taken to the hidden…
6
votes
1 answer

Detecting Significant Device Motion on Android

I've been trying to figure out how to make an application that detects whether the device has been moved a significant amount, something more than just shakes. I am trying to detect a distance of, say, at least a foot. Reading the Training section…
Argent
  • 795
  • 2
  • 7
  • 25
5
votes
0 answers

Detecting total finger touch in Android

I have to take count for the total number of fingers clicked on screen. Used Touch event as below : relTouch.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { …
Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72
5
votes
1 answer

Zoomable SVG with clickable areas - Android

I'm making very simple application. It needs to show one SVG containing generalised world map. By clicking on city's name (svg rectangle), I need to show another SVG that corresponds to that city. Also, all SVGs must support zooming and panning. I…
Aleksandar
  • 1,163
  • 22
  • 41
5
votes
1 answer

My MotionEvent.ACTION_DOWN is not detected

My problem is that all touch events are being detected but not the Action_Down event. the log results in events 1, 2 and not 0 (for down). here is my code final ViewPager homeViewPager = (ViewPager)findViewById(R.id.homeViewPager); …
SoliQuiD
  • 2,093
  • 1
  • 25
  • 29
5
votes
1 answer

Android: Horizontal Recyclerview inside a Vertical Recyclerview

This seems to be a fairly common pattern in android. I'm trying to create something similar to how Facebook displays their adverts: You can see that they have an outer vertical recyclerview with an inner horizontal recyclerview as one of the items…
Simon
  • 19,658
  • 27
  • 149
  • 217
5
votes
1 answer

No break in SwipeRefreshLayout.java in android 5 onInterceptTouchEvent module

I notice in that function there are no break after Action_down, then code can run into ACTION_MOVE, is that right? @Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget(); final int action =…
john vuong
  • 245
  • 2
  • 5
5
votes
4 answers

How to simulate a tap at a specific coordinate in an android webview?

I am able to simulate tap events on typical android views (textbox, button, etc.) using MotionEvent.obtain, like this: int meta_state = 0; MotionEvent motionEvent = MotionEvent.obtain( SystemClock.uptimeMillis(), …
seibelj
  • 890
  • 2
  • 10
  • 22
5
votes
1 answer

event.getAction() never use MotionEvent.ACTION_UP

i have a problem with MotionEvent in the OnTouchListener. The ACTION_DOWN works perfectly, but it never use ACTION_UP I really don't know where is my problem, so if someone can help me with it, that would be really great, thank you. public class…
R00t
  • 186
  • 1
  • 2
  • 14
5
votes
1 answer

how does detecting touch position on android screen work?

We can get the coordinates of the touch position on the screen using the following functions: public boolean onTouchEvent(MotionEvent event){ float x_forOnTouch = event.getX(); float y_forOnTouch = event.getY(); What exactly is being…
user13267
  • 6,871
  • 28
  • 80
  • 138
1
2
3
31 32