Friday 15 May 2015

android MotionEvent when finger enter or leaves view -


I can not develop the game named "Balda".

I have 2D grids of images (or button, maybe) the user should be able to move his finger to the grid, and the app should know that the image in the grid is touching the move Were there So, what I am trying to achieve in the picture below. A. - The starting point where the user pressed on the screen. B. The end point is where the finger leaves the screen. And I have to know how the images were touched (blue in the picture).

I know that I can do something like that. But I think this is a wrong solution, because it is contrary to the principle of giving functionality by liability. I think this is the responsibility of ImageView to know when the finger enters its boundaries and when it leaves its boundaries I thought it would be in the Android API. And it has a motion event like EVENT_HOVER_ENTER and EVENT_HOVER_LEAVE but it is not working with the finger. After the finger is pressed on some, it will receive all other MotionEvents, if I find it right.

I think this is wrong. What can I do to get this functionality? Maybe I can create some custom listeners and custom views, which they support?

Enter image details here

< Div class = "post-text" itemprop = "text">

I think your requirement is similar to the custom gridview.

You can follow the steps below -

1) Create Custom View

2) Attach the Touchlist to it.

3) Divide this view into 4 * 3 matrix.

4) Map your pictures for this 4 * 3 matrix

5) Write a function that returns the cell number of the broken coordinates

6 ) After receiving the cell number; Get the mapped image for that cell number

7) Insert the image in the list

8) When the user raises his finger, you will get the image of the captured images

9) Remember to put this custom view into your activity.

Tell me if you have any doubts or concerns < / Html>

No comments:

Post a Comment