-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use in a ViewPager #30
Comments
I have a view pager and it works correctly, the drawback is that you should be able to detect if imageView is zoomed for desactive viewPager paging. If not, you cannot move or zoom to left/right. |
How are you placing it in the ViewPager? With an image, or loaded with an AsyncTask? Do you have a custom OnTouchListener? |
I have a custom ViewPager that can disable paging. Then i just use a GestureImageView. I have modified the gesture imageView to have a function called isZoomed(). Then i put a touchListener to theGestureImageView, and if it isZoomed() i do ViewPager.setPagingEnabled(false), else setPagingEnabled(true). That way you can't pass to the next /prior image if it is zoomed. This code has a litlle problem, if you do a double tap to disable zoom, its not detected, so isZoomed is not false and you would not be able to switch to next image. If you do pinch to disable zoom works perfect. public class ViewPagerDisable extends ViewPager {
} In gestureImageView.java... public boolean isZoomed() { In GestureImageViewTouchListener.java modify this... private boolean isZoomed = false;
protected void handleScale(float scale, float x, float y) {
|
Thank you, that's very helpful. |
Apart from changes you metioned I have assigned isZoomed here, and seems to work when zooming in/out with double tap: In GestureImageViewTouchListener:
|
I have been 2 week in holidays. I have just tried it, works perfect your fix! Thanks! |
I solve problem with setting zoom after pinch. public boolean onTouch(View v, MotionEvent event) |
If it helps anyone I've combined the various changes mentioned above and put them on this branch: https://github.com/brk3/gesture-imageview/compare/topic/issue-30-isZoomed (Don't have time to format a pull request right now, also the code uses tabs which is really annoying - I can't get my editor to match up properly.) Update People struggling with this lib should check out PhotoView by Chris Banes. It handles ViewPager and fixes a lot of other issues I've been experiencing. |
@brk3 thanks, i've created pull request based on your code modifications |
Work around common limitation with GestureImageView when using with ViewPager. Requires some modifications to GestureImageView outlined at jasonpolites/gesture-imageview#30
Thanks all of you,your response solved my problem!!! |
I've found out very interesting solution!
and @kirich1409's:
|
@jonasasx |
My project has a web gallery where you can swipe through photos. It would be nice to have zooming and panning.
I tried setting the ViewPager's ontouchlistener, to the GestureImageView's TouchListener, but no success. Either nothing happens, or the images become black.
Any ideas?
The text was updated successfully, but these errors were encountered: