-
Notifications
You must be signed in to change notification settings - Fork 386
Usage
Alex Vasilkov edited this page Apr 4, 2017
·
9 revisions
Just add GestureImageView
to your layout:
<com.alexvasilkov.gestures.views.GestureImageView
android:layout_width="match_parent"
android:layout_height="match_parent" />
Or add GestureFrameLayout
:
<com.alexvasilkov.gestures.views.GestureFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- GestureFrameLayout can contain only one child -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Layout content goes here -->
</FrameLayout>
</com.alexvasilkov.gestures.views.GestureFrameLayout>
GestureViews
can be customised using gestureView.getController().getSettings()
:
gestureView.getController().getSettings()
.setMaxZoom(2f)
.setDoubleTapZoom(-1f) // Falls back to max zoom level
.setPanEnabled(true)
.setZoomEnabled(true)
.setDoubleTapEnabled(true)
.setRotationEnabled(false)
.setRestrictRotation(false)
.setOverscrollDistance(0f, 0f)
.setOverzoomFactor(2f)
.setFillViewport(false)
.setFitMethod(Settings.Fit.INSIDE)
.setGravity(Gravity.CENTER);
Note: example above shows default values, you will not need to set them yourself.
See also full settings list with descriptions.
If you plan to use GestureViews
inside ViewPager
you should additionally call:
gestureView.getController().enableScrollInViewPager(viewPager);
You can listen for state changes (position, zoom, rotation):
addOnStateChangeListener(OnStateChangeListener listener)
removeOnStateChangeListener(OnStateChangeListener listener)
You can also listen for additional gestures:
- onDown
- onUpOrCancel
- onSingleTapUp
- onSingleTapConfirmed
- onLongPress
- onDoubleTap
with:
setOnGesturesListener(OnGestureListener listener)
See Basic animations and Advanced animations pages for more info.
See Custom views page.
See Image cropping page.