I’ve programmed a zoomable gallery with several images.
- The images can be zoomed.
- Zoomed images can be dragged.
- If the image is not zoomed, the gallery can be scrolled.
The layout consists of a LinearLayout with a TextView (the name of the gallery) and the Gallery itself.
An item in the gallery consists of a RelativeLayout containing a FrameLayout with the ImageView in it (I read I need the FrameLayout for zooming) and a TextView to show the zoom state of the image.
I’ve used a custom View.OnTouchListener to implement the zooming.
Now I was trying to replace the image in the ImageView after the gallery has stopped scrolling with a high res picture so the user can zoom in much better/further.
I did this with the OnItemSelectedListener and setCallbackDuringFling to false.
Even this works fine if you fling the screen fast.
But if you keep your finger on the display and move it slowly to the edge, the OnItemSelectedListener is fired before the next item reached the center and the scrolling animation stops. Instead the gallery jumps like it looses touch contact and centers the next item in the gallery immediately. Also the OnItemSelectedListener is called more than once on the same item when moving the finger slowly (I avoid this problem by saving the position of the last selected item).
So (long story short) I was looking for a callback/listener to the “scrolling/snap-to-grid” effect of the Gallery. I also tried an AnimationListener, but the gallery returns null when i call getAnimation on it.
I’m desperate here… can anyone help?
Problem solved: I’m now using the
android.support.v4.view.ViewPagerwith the custom callbacks in theOnPageChangeListener:onPageSelectedonPageScrollStateChangedonPageScrolled