ontouch

Returning true and false in OnTouch?

梦想的初衷 提交于 2019-12-19 03:46:44
问题 Does it matter if i return true or false in onTouch() of an OnTouchListener ? I can't see any difference between returning true or false in this example: Android Swipe on List 回答1: The return value determines if you consumed the touch event. In other words true means that this touch event is interesting to you and all follow up calls of this touch event like ACTION_MOVE or ACTION_UP will be delivered to you. If you return false than the touch event will be passed to the next View further up

Android: how to know if user is still touching screen from last activity

我只是一个虾纸丫 提交于 2019-12-12 06:20:21
问题 I've an activity with an imageView, when user touches it, I open another activity with another imageView in the same place as the previous one, question is , I need to know if the user is still touching the imageView & never left his finger of the screen since the last activity (so I can let him move the new imageView around with his finger)? I tried to listen to the touch event, but touch event fires only when user starts touching the imageView after the view is being rendered, so he has to

Trying to get the x, y coordinate of each random circle that is drawn in android [duplicate]

给你一囗甜甜゛ 提交于 2019-12-11 21:09:35
问题 This question already has answers here : Trying to get the x, y coordinate of each random circle that is drawn on the screen (2 answers) Closed 4 years ago . I am making a game that will create random circles on the screen. The circles created randomly will have the value red or green. My question is that I would like to be able to not only determine when a user clicks on one of the circles but determine what circle they have ultimately clicked on (red or green). My main problem is trying to

Android OnTouch swipe up/down direction change

这一生的挚爱 提交于 2019-12-11 06:34:38
问题 I'm trying to detect when an swipe direction was changed while the user still swipes on the screen. I have something like this (very basic) for detecting the swipe direction: @Override public boolean onTouch(View view, MotionEvent motionEvent) { int action = motionEvent.getActionMasked(); switch (action) { case MotionEvent.ACTION_DOWN: { Log.d(TAG, "onTouch: DOWN _Y = " + motionEvent.getRawY()); mLastTouchY = mPrevTouchY = motionEvent.getRawY(); break; } case MotionEvent.ACTION_MOVE: { Log.d

Detecting Swipe and Tap gestures

╄→尐↘猪︶ㄣ 提交于 2019-12-09 19:41:55
问题 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 =

Rotate Frame layout which contains dynamic buttons

放肆的年华 提交于 2019-12-05 20:09:33
问题 I have a Framelayout which add four imageview at runtime as well in center it contains main image with which user can perform different action but i face the problem with rotate layout view currently on touch of rotate button i'm doing this public void setRotateListener() { mRotateImage.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { float x = event.getX(0); float y = event.getY(0); float theta = getTheta(x, y); switch (event.getAction(

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)

Rotate Frame layout which contains dynamic buttons

☆樱花仙子☆ 提交于 2019-12-04 02:32:39
I have a Framelayout which add four imageview at runtime as well in center it contains main image with which user can perform different action but i face the problem with rotate layout view currently on touch of rotate button i'm doing this public void setRotateListener() { mRotateImage.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { float x = event.getX(0); float y = event.getY(0); float theta = getTheta(x, y); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_POINTER_DOWN: theta_old = theta; break; case

Android: handling clicks on image view inside recycler's view item using touch framework

萝らか妹 提交于 2019-12-03 22:44:32
问题 I am trying to capture the clicks on ImageView which is enclosed inside the RecyclerView item. I have implemented RecyclerView.OnItemTouchListener and has gesture detector process the motion events for normal clicks and long press on RecyclerView item. Since I want to have the same touch framework to process touch event on child views inside the RecylcerView item, I have set View.OnTouchListener with the image view as well, overriding the onTouch implementation returning true hoping that the

Android: handling clicks on image view inside recycler's view item using touch framework

a 夏天 提交于 2019-12-01 02:09:45
I am trying to capture the clicks on ImageView which is enclosed inside the RecyclerView item. I have implemented RecyclerView.OnItemTouchListener and has gesture detector process the motion events for normal clicks and long press on RecyclerView item. Since I want to have the same touch framework to process touch event on child views inside the RecylcerView item, I have set View.OnTouchListener with the image view as well, overriding the onTouch implementation returning true hoping that the touch shall be consumed by the ImageView when it gets clicked. I am intentionally returning false in