Getting onTouch() when user's finger is already on the screen - android

I dynamically create a View with onTouchListner. The problem is it doesn't work when the view is being created the same time the user keeps his finger on the screen.
To trigger onTouch() user has to put his finger off the screen and touch it again.
How to solve that?

May be you can try to track coordinates of the touch event when user moves the finger.If the Coordinates are in your views coordinates boundary you can intercept that event and play sound.

Related

Drop coordinates in Android

I want the coordinates of the finger when user drops the object and remove the finger.
I got the position of user when touch the screen but not getting the coordinates when user remove the finger
I'm not sure what exactly you're doing. But onTouchListener gives you all the information about any user interaction event. Event.ACTION_DOWN is when the user starts the event, and Event.ACTION_UP is when the user ends the event (removes their finger)

OpenGL sprite looses focus on fast move

I'm making simple app where user can move squares with finger on screen. First I'm checking if touch coords are on square to allow the move. Then square is moving along GLSurfaceView#onTouchEvent event coordinates.
It works OK. But when finger is moving too quick (like swipe) square looses the focus and stays still. It seems that OpenGL renders square after the move event occurs, so coordinates check fail.
Please point some keywords to figure out the question (googling gives same links again and again) or some docs. Thanks.
You need hold focus on sprite. If sprite got event "down" it holds focus until doesn't get "up" or "cancel" event. So, while sprite holds focus all touch events send to it.

How to touch and pull text to rotate around a circle on Android?

I have some text on circles, and I would like the user to be able to touch and drag the text, and have it constrained to move along the circle...
I got this far using Canvas, but I can't figure out how to make it respond to touch this way. I am not objected to starting over and taking a non-canvas approach.
How can I make this happen? Pseudocode would be appreciated.
I might be wrong, but considering this is a canvas. Then, it is your job to detect which text is touched.
Once you set your onTouchListener for the view, you get the event coordinates of the ACTION_DOWN event. You check and get the text that was touched. If none, return false. Else, return true.
Now, if the user moves his finger, you will receive more events with ACTION_MOVE. In that case, you would probably want to move the chosen text according to the difference between this event and the last one. Once you calculate the new position of the texts, you call invalidate() which should force a redraw.
Finally, when the user stops moving, you will receive an event with ACTION_UP. That is when you have to either put the texts back to their original position, or whatever you want.

dispatching touch events

I have 12 horoscope sign images which are placed in 360 degree circular position. ImageButtons are being used to display the horoSignImages. ImageButton has selector that show pressed and unpressed states for horosSignImage. The signWheel rotates by using gestuer.
Problem is that, When i tap right over the horosignImage to rotate the wheel, the imageButton catches the event and wheel is not rotated upon scrolling the finger. I want to animate the image its pressed state when the user taps right over it, meanwhile the wheel should rotate if the user scrolls his finger. Wheel rotation only works if i tap outside the horosignImage and scroll the finger.
Any suggestions to solve this problem?
Sadly I don't have the answer, but your problem seems to be similar to Passing touch events to the parent view
In both cases you want the touch event handled by the imageButton as well as the signWheel.

What is the purpose of "onFling" and "onScroll" event in GestureDetector of Android?

I am developing an Android application. I am novice in Touch enabled Android Application. I have read the article about onFling and onScroll events on:
http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html
But I didn't get exactly what is the meaning and for what we can use onFling and onScroll events.
onScroll event is when user touches down the screen, moves finger in some direction and lift up. It is mostly used to scroll larger layouts over a smaller viewport. onFling is the same, but made faster and usually triggers an animation that keeps scrolling few moments more after finger lifted up.

Categories

Resources