was trying to add this "gesture" function to my first program, and almost every search I did came to this thread:
Fling gesture detection on grid layout
I was able to get it working.. but in my case, I am not sure if it's 100 % correct.
In my layout, I have 3 horizontal linearLayouts, each one has 5 buttons.. so it's 3 columns of 5 buttons.. according to the thread I had to:
"Attach your gesture listener to all the views you add to the main layout;"
that means for all the 15 buttons:
"button.setOnTouchListener(gestureListener);"
Couldn't I just say that the LinearLayouts with the buttons are the ones looking out for the swipe gestures? Or because they are "hidden" on the back of the buttons, this can't be done?
Because I have another layout I want to implement with this, and it has even more buttons..
So .. just looking for a simpler way of detecting on my screen for swipe right | left .. if it does exists..
Thank you in advance
From Settings, search for and select Navigation bar. Tap Navigation bar again, and then select Full screen gestures. Tap More options under Full screen gestures, and then choose the new option for Swipe from the sides and bottom.
Scroll down to Settings and tap. Tap General settings. Scroll to Email swipe actions and tap. Tap Change next to the right swipe and left swipe, and pick the action you'd like to occur when you swipe.
Couldn't I just say that the LinearLayouts with the buttons are the ones looking out for the swipe gestures? Or because they are "hidden" on the back of the buttons, this can't be done?
I think that's precisely the problem you're going to face unless you detect the swipe on all visual objects.
The more buttons (or other widgets) on the screen, the more accurate a user will have to be when they start/end the swipe gesture - in other words they'd need to start/end both in gaps between your buttons.
To detect a swipe requires start and end locations - if the user starts and ends on buttons (which aren't listening for the swipe) then a swipe won't be detected. Similarly, starting on a button and ending in a 'gap' (or vice versa) won't detect a valid swipe either because only one of the start/end points is valid for 'swipe detection'.
The best approach I can think of (although I've never tried myself) is to use a GestureOverlayView. This allows you to have a transparent overlay on top of your background view(s) and can be used to detect things like 'swipe' without your underlying views needing to know about gestures.
See this in the developers resources Gestures
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With