library / com.otaliastudios.zoom / ZoomApi

ZoomApi

interface ZoomApi

An interface for zoom controls.

Annotations

AbsolutePan

Annotation to indicate an AbsolutePan value.

annotation class AbsolutePan

Alignment

Defines the available alignments

annotation class Alignment

RealZoom

Annotation to indicate a RealZoom value.

annotation class RealZoom

ScaledPan

Annotation to indicate a ScaledPan value.

annotation class ScaledPan

Transformation

Defines the available transformation types

annotation class Transformation

Zoom

Annotation to indicate a zoom value.

annotation class Zoom

ZoomType

Defines the available zoom types

annotation class ZoomType

Properties

pan

The current pan as an AbsolutePoint.

abstract val pan: AbsolutePoint

panX

Returns the current horizontal pan value, in content absolute coordinates (that is, as if there was no zoom at all).

abstract val panX: Float

panY

Returns the current vertical pan value, in content absolute coordinates (that is, as if there was no zoom at all).

abstract val panY: Float

realZoom

Gets the current zoom value, including the base zoom that was eventually applied when initializing to respect the "center inside" policy. This will match the scaleX - scaleY values you get into the Matrix, and is the actual scale value of the content from its original size.

abstract val realZoom: Float

scaledPan

The current pan as a ScaledPoint, that is, taking into account the current zoom. This basically returns the pan value multiplied by the current realZoom.

abstract val scaledPan: ScaledPoint

scaledPanX

Returns the current horizontal pan value, in content scaled coordinates (that is, including the current zoom). This is equivalent to panX multiplied by realZoom.

abstract val scaledPanX: Float

scaledPanY

Returns the current vertical pan value, in content scaled coordinates (that is, including the current zoom). This is equivalent to panY multiplied by realZoom.

abstract val scaledPanY: Float

zoom

Gets the current zoom value, which can be used as a reference when calling ZoomApi.zoomTo or ZoomApi.zoomBy.

abstract val zoom: Float

Functions

cancelAnimations

Cancels all currently active animations triggered by either API calls with animate = true or touch input flings. If no animation is currently active this is a no-op.

abstract fun cancelAnimations(): Boolean

getMaxZoom

Get the currently allowed max zoom. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.

abstract fun getMaxZoom(): Float

getMaxZoomType

Get the currently set max zoom type.

abstract fun getMaxZoomType(): Int

getMinZoom

Get the currently allowed min zoom. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.

abstract fun getMinZoom(): Float

getMinZoomType

Get the currently set min zoom type.

abstract fun getMinZoomType(): Int

moveTo

A low level API that can animate both zoom and pan at the same time. Zoom might not be the actual matrix scale, see ZoomApi.zoom and ZoomApi.realZoom. The coordinates are referred to the content size so they do not depend on current zoom.

abstract fun moveTo(zoom: Float, x: Float, y: Float, animate: Boolean): Unit

moveToCenter

Moves to the center of the content.

abstract fun moveToCenter(zoom: Float? = null, animate: Boolean): Unit

panBy

Pans the content by the given quantity in dx-dy values. These are referred to the content size so they do not depend on current zoom.

abstract fun panBy(dx: Float, dy: Float, animate: Boolean): Unit

panTo

Pans the content until the top-left coordinates match the given x-y values. These are referred to the content size so they do not depend on current zoom.

abstract fun panTo(x: Float, y: Float, animate: Boolean): Unit

realZoomTo

Animates the actual matrix zoom to the given value.

abstract fun realZoomTo(realZoom: Float, animate: Boolean): Unit

setAlignment

Sets the content alignment. Can be any of the constants defined in com.otaliastudios.zoom.Alignment. The content will be aligned and forced to the specified side of the container. Defaults to ALIGNMENT_DEFAULT.

abstract fun setAlignment(alignment: Int): Unit

setAllowFlingInOverscroll

Controls whether fling events are allowed when the view is in an overscrolled state.

abstract fun setAllowFlingInOverscroll(allow: Boolean): Unit

setAnimationDuration

Sets the duration of animations triggered by zoom and pan APIs. Defaults to ZoomEngine.DEFAULT_ANIMATION_DURATION.

abstract fun setAnimationDuration(duration: Long): Unit

setFlingEnabled

Controls whether fling gesture is enabled or not.

abstract fun setFlingEnabled(enabled: Boolean): Unit

setHorizontalPanEnabled

Controls whether horizontal panning using gestures is enabled.

abstract fun setHorizontalPanEnabled(enabled: Boolean): Unit

setMaxZoom

Which is the max zoom that should be allowed. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.

open fun setMaxZoom(maxZoom: Float): Unit
abstract fun setMaxZoom(maxZoom: Float, type: Int): Unit

setMinZoom

Which is the min zoom that should be allowed. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.

open fun setMinZoom(minZoom: Float): Unit
abstract fun setMinZoom(minZoom: Float, type: Int): Unit

setOneFingerScrollEnabled

Controls whether one finger scroll gesture is enabled or not.

abstract fun setOneFingerScrollEnabled(enabled: Boolean): Unit

setOverPanRange

Set the OverPanRangeProvider that specifies the amount of overpan to allow.

abstract fun setOverPanRange(provider: OverPanRangeProvider): Unit

setOverPinchable

Controls whether the content should be overPinchable. If it is, pinch events can change the zoom outside the safe bounds, than return to safe values.

abstract fun setOverPinchable(overPinchable: Boolean): Unit

setOverScrollHorizontal

Controls whether the content should be over-scrollable horizontally. If it is, drag and fling horizontal events can scroll the content outside the safe area, then return to safe values.

abstract fun setOverScrollHorizontal(overScroll: Boolean): Unit

setOverScrollVertical

Controls whether the content should be over-scrollable vertically. If it is, drag and fling vertical events can scroll the content outside the safe area, then return to safe values.

abstract fun setOverScrollVertical(overScroll: Boolean): Unit

setOverZoomRange

Set the OverZoomRangeProvider that specifies the amount of overzoom to allow.

abstract fun setOverZoomRange(provider: OverZoomRangeProvider): Unit

setScrollEnabled

Controls whether scroll gesture is enabled or not.

abstract fun setScrollEnabled(enabled: Boolean): Unit

setThreeFingersScrollEnabled

Controls whether three fingers scroll gesture is enabled or not.

abstract fun setThreeFingersScrollEnabled(enabled: Boolean): Unit

setTransformation

Sets the base transformation to be applied to the content. See setTransformation.

open fun setTransformation(transformation: Int): Unit

Sets the base transformation to be applied to the content. Defaults to TRANSFORMATION_CENTER_INSIDE with android.view.Gravity.CENTER, which means that the content will be zoomed so that it fits completely inside the container.

abstract fun setTransformation(transformation: Int, gravity: Int): Unit

setTwoFingersScrollEnabled

Controls whether two fingers scroll gesture is enabled or not.

abstract fun setTwoFingersScrollEnabled(enabled: Boolean): Unit

setVerticalPanEnabled

Controls whether vertical panning using gestures is enabled.

abstract fun setVerticalPanEnabled(enabled: Boolean): Unit

setZoomEnabled

Controls whether zoom using pinch gesture is enabled or not.

abstract fun setZoomEnabled(enabled: Boolean): Unit

zoomBy

Applies the given factor to the current zoom.

abstract fun zoomBy(zoomFactor: Float, animate: Boolean): Unit

zoomIn

Applies a small, animated zoom-in.

abstract fun zoomIn(): Unit

zoomOut

Applies a small, animated zoom-out.

abstract fun zoomOut(): Unit

zoomTo

Zooms to the given scale. This might not be the actual matrix zoom, see ZoomApi.zoom and ZoomApi.realZoom.

abstract fun zoomTo(zoom: Float, animate: Boolean): Unit

Companion Object Properties

ALIGNMENT_DEFAULT

The default value for setAlignment.

const val ALIGNMENT_DEFAULT: Int

MAX_ZOOM_DEFAULT

The default setMaxZoom applied by the engine if none is specified.

const val MAX_ZOOM_DEFAULT: Float

MAX_ZOOM_DEFAULT_TYPE

The default setMaxZoom type applied by the engine if none is specified.

const val MAX_ZOOM_DEFAULT_TYPE: Int

MIN_ZOOM_DEFAULT

The default setMinZoom applied by the engine if none is specified.

const val MIN_ZOOM_DEFAULT: Float

MIN_ZOOM_DEFAULT_TYPE

The default setMinZoom type applied by the engine if none is specified.

const val MIN_ZOOM_DEFAULT_TYPE: Int

TRANSFORMATION_CENTER_CROP

Constant for ZoomApi.setTransformation. The content will be zoomed so that its smaller side fits exactly inside the container. The larger side will be partially cropped.

const val TRANSFORMATION_CENTER_CROP: Int

TRANSFORMATION_CENTER_INSIDE

Constant for ZoomApi.setTransformation. The content will be zoomed so that it fits completely inside the container.

const val TRANSFORMATION_CENTER_INSIDE: Int

TRANSFORMATION_GRAVITY_AUTO

Constant for ZoomApi.setTransformation gravity. This means that the gravity will be inferred from the alignment or fallback to a reasonable default.

const val TRANSFORMATION_GRAVITY_AUTO: Int

TRANSFORMATION_NONE

Constant for ZoomApi.setTransformation. No transformation will be applied, which means that both ZoomApi.zoom and ZoomApi.realZoom will return the same value.

const val TRANSFORMATION_NONE: Int

TYPE_REAL_ZOOM

Flag for zoom constraints and settings. With ZoomApi.TYPE_REAL_ZOOM the constraint is measured over the zoom in ZoomApi.realZoom, which is the actual scale you get in the matrix.

const val TYPE_REAL_ZOOM: Int

TYPE_ZOOM

Flag for zoom constraints and settings. With ZoomApi.TYPE_ZOOM the constraint is measured over the zoom in ZoomApi.zoom. This is not the actual matrix scale value.

const val TYPE_ZOOM: Int

Inheritors

ZoomEngine

A low level class that listens to touch events and posts zoom and pan updates. The most useful output is a Matrix that can be used to do pretty much everything, from canvas drawing to View hierarchies translations.

open class ZoomEngine : ZoomApi

ZoomImageView

Uses ZoomEngine to allow zooming and pan events to the inner drawable.

open class ZoomImageView : ImageView, ZoomApi

ZoomLayout

Uses ZoomEngine to allow zooming and pan events onto a view hierarchy. The hierarchy must be contained in a single view, added to this layout (like what you do with a ScrollView).

open class ZoomLayout : FrameLayout, OnGlobalLayoutListener, ZoomApi

ZoomSurfaceView

Uses ZoomEngine to allow zooming and pan events onto a GL rendered surface.

open class ZoomSurfaceView : GLSurfaceView, ZoomApi, Renderer