motionevent

AndroidStudio MotionEvent: detect only ACTION_UP on a second view, starting ACTION_DOWN on first view

一个人想着一个人 提交于 2019-12-08 09:39:24
问题 Solved it by using emandt's suggestion. My personal Solution added below. I'm using Android Studio for this. I searched for solutions but couldn't find anything resembling this. I want to know on which ImageView an UP action occurs while starting the DOWN action on a different ImageView (to eventually be able to drag one image over the other and make it snap to the same position by getting the position of the image I dragged over). My example has two ImageViews with the id imageView (left)

Android/Processing MotionEvent getX() raises exception

被刻印的时光 ゝ 提交于 2019-12-08 08:34:38
问题 I'm new to android development so bear with me. I've written a processing script that works with two simultaneous presses. To do this I'm using android.view.motionevent. In my main script (pde) I have this: public boolean surfaceTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { //do action down stuff... } //etc do other actions... This works fine. The problem comes in handling the ACTION_MOVE: //ACTION_MOVE else if (event.getActionMasked() ==

view/motionEvent cannot be resolved to a variable swipe

夙愿已清 提交于 2019-12-08 03:30:09
问题 I have got this code from another stackoverflow question: import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; public class OnSwipeTouchListener implements OnTouchListener { private final GestureDetector gestureDetector = new GestureDetector(new GestureListener()); public boolean onTouch(final View v, final MotionEvent event) { super.onTouch(view,

Zoomable SVG with clickable areas - Android

只愿长相守 提交于 2019-12-06 09:42:01
问题 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 managed to make SVGs support zooming and panning and that works perfect. For that purpose, I'm using svg-android library for rendering SVGs and customized TouchImageView for panning, zooming and capturing scale and touch events. But, it seems to be

Rotation of layout changes the co-ordinate of the motion event

邮差的信 提交于 2019-12-06 08:40:56
i am cropping a image by the help of a child relative layout and i am moving it by motion event over a parent relative layout(containing image-view to be cropped). ..but when i rotate parent layout (in which i have the image view ) by 90 deg. the behavior of motion event co-ordinate changes,and does not work(drag and zoom of child layout)properly.. please somebody tell me how to fix this..i have done some research and found about the AXIS_ORIENTATION in motionevent class but did not get any example regarding to it. thanks in advance :) 来源: https://stackoverflow.com/questions/28766334/rotation

Simulate smooth Drag Event programmatically

孤者浪人 提交于 2019-12-06 07:02:05
问题 I used custom DragLinearLayout. All child I added using addDragView() are draggable (user interaction). I want to simulate Drag Event for clicked View (smooth move to the bottom of Layout). ACTION_DOWN -> ACTION_MOVE -> ACTION_UP I tried this code, but it didn't work. long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); float x = view.getLeft(); float y = view.getTop(); int metaState = 0; MotionEvent downEvent = MotionEvent.obtain( downTime, eventTime +

Detecting Swipe and Tap gestures

心已入冬 提交于 2019-12-04 17:15:27
How to detect Swipe and Tap in onTouch method? I want one of two actions to be executed when I swipe and other when I just tap. Need to know how to dell the difference between tap and swipe. Here is my code: @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE) { mGestureDetector.onTouchEvent(event); } switch(event.getAction()) { case MotionEvent.ACTION_DOWN: x1 = event.getX(); y1 = event.getY(); break; case MotionEvent.ACTION_UP: x2 = event.getX(); y2 = event.getY(); float deltaX = x2 - x1; float deltaY = y2 - y1; if (Math.abs(deltaX)

Zoomable SVG with clickable areas - Android

半世苍凉 提交于 2019-12-04 15:40:11
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 managed to make SVGs support zooming and panning and that works perfect. For that purpose, I'm using svg-android library for rendering SVGs and customized TouchImageView for panning, zooming and capturing scale and touch events. But, it seems to be impossible to make clickable regions on SVGs in Android. I tried brute force, to recalculate position

Simulate smooth Drag Event programmatically

Deadly 提交于 2019-12-04 11:51:09
I used custom DragLinearLayout . All child I added using addDragView() are draggable (user interaction). I want to simulate Drag Event for clicked View (smooth move to the bottom of Layout). ACTION_DOWN -> ACTION_MOVE -> ACTION_UP I tried this code, but it didn't work. long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); float x = view.getLeft(); float y = view.getTop(); int metaState = 0; MotionEvent downEvent = MotionEvent.obtain( downTime, eventTime + 1000, MotionEvent.ACTION_DOWN, x, y, metaState ); view.dispatchTouchEvent(downEvent); MotionEvent

Movement of simultaneous two bitmap on a view with MotionEvent

ぐ巨炮叔叔 提交于 2019-12-04 02:01:28
问题 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.