motionevent

onInterceptTouchEvent never receives action_move

為{幸葍}努か 提交于 2019-12-03 08:56:30
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 views, an ImageView and a GridLayout. My intercept code is: @Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: logD ("DDV Intercept DOWN"); break; case MotionEvent.ACTION_POINTER_DOWN: logD ("DDV Intercept P DOWN"); // logD: shell

Simulate a mouse input on android

落花浮王杯 提交于 2019-12-03 08:29:16
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 displayed on screen. The events I am sending look like these: 05-14 13:38:05.043: I/onTouchEvent(30301): MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=498.0, y[0]=996.0, toolType[0]=TOOL_TYPE_MOUSE, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=251957430, downTime=251957420, deviceId=1, source

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

蓝咒 提交于 2019-12-03 02:33:31
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 them? MotionEvent: ACTION_UP: A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event. ACTION_CANCEL: The current gesture has been aborted. ACTION_CANCEL occurs when the parent takes possession of the motion, for example when the user has dragged enough

What causes a MotionEvent.ACTION_CANCEL in Android?

若如初见. 提交于 2019-12-02 23:27:05
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 hoping someone could point me in the right direction for debugging this problem - error codes, source code, or some general knowledge. 0gravity Is this what you are looking for: "ACTION_CANCEL occurs when the parent takes possession of the motion, for example when the user has dragged enough across a list view that it will start scrolling instead of

Movement of simultaneous two bitmap on a view with MotionEvent

。_饼干妹妹 提交于 2019-12-01 12:18:48
I created two bitmap on my view using the following class (Simple 2D Graphics in android) and wandering to achieve that bitmap can move independently. I am calling motionevent method for this. Current issue, i do not understand why does only one object is moving right in the following code. e.g. with this code, only "not" bitmap is moved, i would like to move both bitmaps independently of eachother. scenrio: i can use my two fingures, one for each object, to move the bitmaps independently. but i don't know how to achieve this. public class TouchView extends View { private Drawable cross;

Why does ACTION_OUTSIDE return 0 everytime on KitKat 4.4.2?

牧云@^-^@ 提交于 2019-12-01 08:34:44
I have implemented a window with size 1 and want to catch ACTION_OUTSIDE event. mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(1,1, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); I get the trigger and I get the ACTION_OUTSIDE event, but when reading event.getRawX() and event.getRawY() they both return 0 every time. I tested the same thing with

Why does ACTION_OUTSIDE return 0 everytime on KitKat 4.4.2?

旧时模样 提交于 2019-12-01 06:06:43
问题 I have implemented a window with size 1 and want to catch ACTION_OUTSIDE event. mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(1,1, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); I get the trigger and I get the ACTION_OUTSIDE event, but when

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

喜欢而已 提交于 2019-11-30 08:23:56
问题 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 scrolling. Similarly, when the user is scrolling up, first the ListView (order reversed here!) should scroll up, before the ScrollView starts scrolling. So far I have done the following: listView.setOnTouchListener(new View.OnTouchListener() { // Setting on

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

寵の児 提交于 2019-11-30 03:11:33
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, because I read it, and I don't see any parameter I can supply to either of the methods to get something different. public final int getAction () and public final int getActionMasked() C James Yes, they both return the action (up/down etc.), but getAction() may return the action with pointer information, in which case the events may be a little

Android : Get view only on which touch was released

浪尽此生 提交于 2019-11-29 12:17:57
I am in a tricky situation, hope you can help me with it. I have few views (TextViews), horizontally placed one after another in a linear layout. When I press on textview1, drag my finger to any other textview and release touch, I want to be able to get the view(textview) on which the finger was lifted. I went over the TouchListener api, it says that every event starts with a ACTION_DOWN event action. Since other textviews won't fire that event, how can I get the reference to the textViews on which I lifted my finger? I tried it even, and the action_up would fire only on the textView that