RagAnt
RagAnt

Reputation: 1014

Using TouchImageView in RecyclerView attached with PageSnapHelper?

My app is doing a gallery which uses TouchImageView on RecyclerView.

I was trying to use this class to display multiple fullscreen images in a RecyclerView attached with PageSnapHelper

This works fine, but the zooming is very awkward to use .If I try to pinch zoom , the image moving left and right but not zooming. Only double Tap works.

I think there is a conflict with the swiping and scrolling of the RecyclerView attached with PageSnapHelper .

How can I make the TouchImageView touch events override the PageSnapHelper events when pinch zoomed byt swiping also works when swiped?

To be simple , I want the same behavior of Chat Apps(Whatsapp and telegram) Image Slider which supports both swiping and pinch zooming

Note , I searched the stackoverflow but there are only solutions for ViewPagers but no recyclerview

Upvotes: 1

Views: 440

Answers (2)

Megala Mani
Megala Mani

Reputation: 97

You can use try this library Subsampling-scale-imageview https://github.com/davemorrissey/subsampling-scale-image-view/tree/master

Upvotes: 1

Robert Tušek
Robert Tušek

Reputation: 1

Im not exactly sure what you are asking here, but if I got it right, the problem is you can't pinch zoom because the RecyclerView is recognising your pinch action as a swipe. If you wanted, you could always disallow the RecyclerView from intercepting the touch event (and handle the event yourself) by calling:

view.parent.requestDisallowInterceptTouchEvent(true)

inside the onTouch method of the PrivateOnTouchListener.

If you want a simpler solution, you could also check if the current view is zoomed or if at least 2 fingers are touching the view. If yes, disallow the parent to intercept the touch event. The inside the PrivateOnTouchListener code would then look like this:

     if (isZoomed || event.pointerCount >= 2) {
        v.parent.requestDisallowInterceptTouchEvent(true)
     }

The parent will now only be allowed to intercept the touch event if the view isn't zoomed and if only one finger is touching the view.

Upvotes: 0

Related Questions