We have the Gallery, which support swiping.
We also have 3rd-party components that support pinch-to-zoom on ImageView, such as ImageViewTouch in ImageViewZoom.
Now I would like to combine them both.
The problem is that the swipe events get consumed by the ImageViewTouch and missed by the Gallery.
How can consume events by both components?
That would solve my problem, because, eventually, after a few events, each component will know how to react accordingly.
For example, if the first event is ACTION_DOWN, it can be part of a pinch-to-zoom or part of a swipe. Both components (Gallery and ImageViewTouch) should consume it in order to know what to do in following events.
I combined both components by changing some code in ImageViewZoom. The change was for the events to return a value if they were consumed by the ImageViewTouch. If so, than the event should not be passed to the gallery. If the event is not consumed by the ImageView, than the gallery should consume it (if it can).
There are still some small issues, but it's functional. Hopefully other people in the community can help.
Here's the fork on github: https://github.com/kilaka/ImageViewZoom
Thanks.
Related
the lazy swipe app opens when user swipes from bottom left corner of the screen diagonally. how is this done? how lazy swipe app is only seen as an arc, and not on the whole screen? I want to make an app like that? please tell me how should I start to make that kind of swipe gesture?
I donw know the app, but there are serval ways to do that.
basically you have to override onInterceptTouchEvent() and onTouchEvent() for your View
or
you can override Activity.onTouchEvent() to let the activity intercept all touch events.
Have a look here:
https://developer.android.com/training/gestures/viewgroup.html
Update:
After reviewing LazySwipe: Lazy Swipe is using the same mechanism / android api as Facebook chats heads. It's not an activity. Basically its a Service. Here is a discussion and implementation. There are also libraries on Github (I have never used that one).
But as you see it's not an Activiy, hence you can not use Activity.onTouch(). However, you can display and interact any regular View or ViewGroup. Therefore, overriding ViewGoroup.onInterceptTouchEvent() and ViewGorup.onTouchEvent() is possible. So yes, you can detect Swipe gestures.
There are alredy some gesture detectors build in on Android that you can use. Have a look here: https://developer.android.com/training/gestures/scroll.html
Simple scenario - ScrollView hosting a single LinearLayout which has several children - the preferred pattern to allow a scroll enabled views in developing on Android.
I need to capture onScrollEvents, start, stop, etc. that are readily available and work very well if I use ListView/onScrollListener combination.
A dedicated widget for scrolling a view DOES NOT have the built-in capabilities to capture these events? Come On! I have tried OnTouchEvent listener, onGestureListener, etc - all work arounds and all meant for something else. What am I missing here?
Unfortunately, there is no pre-built way for getting these events. However, there are two workarounds:
Use a ListView instead
Build your own custom ScrollView with ScrollListener. This is not that hard to achieve and has been done before.
I need to implement a swipe gesture using two finger touch input on my ListView from right to left and vice-versa, but it should work exactly like an app named Clean Master who applied this under its "History" section (check the image) for going from Cache to Residual files (but using sinlgle touch input and i want to implement this using two finger touch input). If you've used this app, can you please tell me how to implement this. I've no idea being new to this concept. Please help me learn.
Is this what you need? Its a library called swipe listview.Its so easy to use and have customization options.
I'd like to make a view in my Android app that flips between multiple views on a swipe/fling. I'd like it to behave more or less like the Android Launcher behaves when flipping between views. In particular,
It should flip views on swipe.
Generally a swipe will flip between one view and the next. It should not fling across all of the views.
If you swipe slowly, you should see the views dragging as you're swiping, eg. the way the Launcher does it.
I tried using a ViewFlipper with a GestureOverlayView as per Romain Guy's blog post here, but there's no indicator to the user as they're swiping. This makes discoverability difficult, which is presumably why Launcher does it the way they do.
I tried using a Gallery object, but when I swipe from left to right, there's a certain amount of momentum that flings the users through all the views rather than just taking them to the next view.
Is there a good way to accomplish what I'm trying to do?
I know this is an old question but ViewPager is created for this exact same purpose. ViewPager is part of android compatibility package and more can be found at http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
Take a look at HorizontalPager. It's actually based on RealViewSwitcher, which in turn is based on the Android homescreen's code, and supports snap-to paging with drag feedback, as well as nested vertically-scrolling subviews. Gesture support for fast swipes isn't all it should be, but this may get you part of the way there (and I'd welcome contributions back).
EDIT: As of 2012 you're much better off using Google's ViewPager - it's in the compat library.
Check out SwipeView within this project https://github.com/fry15/uk.co.jasonfry.android.tools It does exactly what you want it to do and is super simple to implement.
#CommonsGuy extended ViewFlipper to do it.
https://github.com/commonsguy/cwac-viewswiper
Ihaven't used this one yet so im not sure if it moves with your finger like the launcher if not your going to have to make an OnTochListener to do it for you in me.ACTION_MOVE you will update the view to change its position. I'll post some sample code when I get home if you don't get another answer.
I've got the feeling that javascript itself is pretty fast in an andorid webview, but there is a long delay between touching an element and the onclick event beeing fired.
I could imagine that this is a feature if you navigate between pages - you first see the highlight on the element, and then you see the effect (navigation). But for applications, this is too slow.
Is there a way to change this behavior?
Or is there maybe another event I should go for, like an onHover or onTouch? Something which fires way before the onClick?
This is a known 'issue' related to 300ms due to user tapping/zooming at display:
http://updates.html5rocks.com/2013/12/300ms-tap-delay-gone-away
In the near future, this seems to be solved, in static sized layouts, adding information at header. But the actual webkit webview version does not have/consider this option.
In my case, the solution was use Tappy lib:
https://github.com/filamentgroup/tappy
Just import it, and bind to each element that has an click event, and you will see the difference.
Just one more point: I adjusted the timer to 100000ms (default:1000ms) to avoid event repetition in some specific cases.
I guess I've found the answer...
If you take a look at jQuery mobile, you'll find a tap event. This works instantly - exactly as I need it.
Looking deeper into the source, I've found that the tap event uses a mousedown ....