Canvas inside viewpager receives touch event when user swipes - android

I have a canvas in which I am drawing a horizontal line as seen below. I draw this line based on user touch events , and I move the line along y axix only. This canvas is inside viewpager. When I try to swipe to next page canvas detects the touch event and changes the position of line . So how can I differentiate between when user wants to change the position of line or user wants to swipe to next page. I have tried experiments with touch event of pager and canvas , and the fragment that contain canvas , nothing worked as I required. Any help , suggestions appreciated.

Related

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 send touch event equally to gesture Overlay view and Canvas

I do not know what is going on. I am hiding the gesture drawing , rather then this I am planning to show the the drawing drawn by the paint and canvas.I am using the drawing panel class which is working fine if used alone as shown in this question. It is drawing perfectly.
Now what I was thinking and tried is this , I have implemented the gesture overlay view alone and it was working and detecting gesture. But due to some reasons I am manipulating these two methods all together 1.Paint to draw on canvas 2 gesture to recognize user gesture while drawing on Canvas
Now what I am trying and expecting is , When user draw A on canvas the the canvas starting following the user finger and starts drawing but I think as when the gesture overlay starts detecting gesture, it looks like that the touch is passed to gesture overlay view where as the Paint and canvas stops further drawing.
What I want :
I want that the touch event should be received by the canvas and gesture overlay equally , so that they both work independently.
In simple Words , Do you have any idea how to send touch event to both of these equally ?
Ok there it is , I found the solution , if some one also trying to get it , I mean to use Gesture overlay view , while having other child. Just put the following line in the gesture overlay view xml
android:eventsInterceptionEnabled="false"
and it would start working .

How to draw a line between two images in android?

I need to implement a program to join an image from one column to other column. I need do the next:
link: http://imageshack.us/a/img217/6163/exampleoz.png
I have tried with drag and drop (android developers drag and drop) but it isn't what I need because with drag and drop you move the image from one location to another and I don't want to move anything.
I want that when you press one image on the screen, without lifting the finger, and then you move your finger to other image and lift the finger, the two images are matched.
Thank you!!!!!!!!!!!!!!!
In onTouchEvent() :
On ACTION_DOWN store first position (event.getX(), event.getY())
On ACTION_UP store second position.
Draw a line between those 2 points.

Draw the path based on touch events

my activity contains some Buttons and an EditText. I set the onTouchListeners for all the buttons and its aim is to draw the path based on the touch events that happens on buttons(swype keyboard). Problem is that I unable to draw the path.how to make it possible?
post the sample code if possible.

imageview touch event issue in android

I am implementing a drawing canvas and zoom for custom imageview in android. Both are implementing the touch event, if the user touches, I have to draw canvas and if the user flings with two finger I have to zoom imageview. Touch will fire for only one event canvas is working the zoom is not working. Can anybody tell me how to implement these two functionalities?
Thanks
Using a GestureListener you can do it, or you should read all the inputs and make the logic to know what the user is doing.

Categories

Resources