Package 

Interface ZoomApi


  • 
    public interface ZoomApi
    
                        

    An interface for zoom controls.

    • Method Detail

      • setOverScrollHorizontal

         abstract Unit setOverScrollHorizontal(Boolean overScroll)

        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.

        Parameters:
        overScroll - whether to allow horizontal over scrolling
      • setOverScrollVertical

         abstract Unit setOverScrollVertical(Boolean overScroll)

        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.

        Parameters:
        overScroll - whether to allow vertical over scrolling
      • setHorizontalPanEnabled

         abstract Unit setHorizontalPanEnabled(Boolean enabled)

        Controls whether horizontal panning using gestures is enabled.

        Parameters:
        enabled - true enables horizontal panning, false disables it
      • setVerticalPanEnabled

         abstract Unit setVerticalPanEnabled(Boolean enabled)

        Controls whether vertical panning using gestures is enabled.

        Parameters:
        enabled - true enables vertical panning, false disables it
      • setZoomEnabled

         abstract Unit setZoomEnabled(Boolean enabled)

        Controls whether zoom using pinch gesture is enabled or not.

        Parameters:
        enabled - true enables zooming, false disables it
      • setOverPinchable

         abstract Unit setOverPinchable(Boolean overPinchable)

        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.

        Parameters:
        overPinchable - whether to allow over pinching
      • setFlingEnabled

         abstract Unit setFlingEnabled(Boolean enabled)

        Controls whether fling gesture is enabled or not.

        Parameters:
        enabled - true enables fling gesture, false disables it
      • setScrollEnabled

         abstract Unit setScrollEnabled(Boolean enabled)

        Controls whether scroll gesture is enabled or not.

        Parameters:
        enabled - true enables scroll gesture, false disables it
      • setOneFingerScrollEnabled

         abstract Unit setOneFingerScrollEnabled(Boolean enabled)

        Controls whether one finger scroll gesture is enabled or not.

        Parameters:
        enabled - true enables one finger scroll gesture, false disables it
      • setTwoFingersScrollEnabled

         abstract Unit setTwoFingersScrollEnabled(Boolean enabled)

        Controls whether two fingers scroll gesture is enabled or not.

        Parameters:
        enabled - true enables two fingers scroll gesture, false disables it
      • setThreeFingersScrollEnabled

         abstract Unit setThreeFingersScrollEnabled(Boolean enabled)

        Controls whether three fingers scroll gesture is enabled or not.

        Parameters:
        enabled - true enables three fingers scroll gesture, false disables it
      • setAllowFlingInOverscroll

         abstract Unit setAllowFlingInOverscroll(Boolean allow)

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

        Parameters:
        allow - true allows fling in overscroll, false disables it
      • setAlignment

         abstract Unit setAlignment(Integer alignment)

        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.

        Keep in mind that this is disabled when the content is larger than the container, because a forced alignment in this case would result in part of the content being unreachable.

        Parameters:
        alignment - the new alignment
      • moveTo

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

        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.

        Parameters:
        zoom - the desired zoom value
        x - the desired left coordinate
        y - the desired top coordinate
        animate - whether to animate the transition
      • moveToCenter

         abstract Unit moveToCenter(Float zoom, Boolean animate)

        Moves to the center of the content.

        Parameters:
        zoom - the desired zoom value
        animate - whether to animate the transition
      • panTo

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

        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.

        Parameters:
        x - the desired left coordinate
        y - the desired top coordinate
        animate - whether to animate the transition
      • panBy

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

        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.

        In other words, asking to pan by 1 pixel might result in a bigger pan, if the content was zoomed in.

        Parameters:
        dx - the desired delta x
        dy - the desired delta y
        animate - whether to animate the transition
      • zoomTo

         abstract Unit zoomTo(Float zoom, Boolean animate)

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

        Parameters:
        zoom - the new scale value
        animate - whether to animate the transition
      • zoomBy

         abstract Unit zoomBy(Float zoomFactor, Boolean animate)

        Applies the given factor to the current zoom.

        Parameters:
        zoomFactor - a multiplicative factor
        animate - whether to animate the transition
      • zoomIn

         abstract Unit zoomIn()

        Applies a small, animated zoom-in.

      • zoomOut

         abstract Unit zoomOut()

        Applies a small, animated zoom-out.

      • realZoomTo

         abstract Unit realZoomTo(Float realZoom, Boolean animate)

        Animates the actual matrix zoom to the given value.

        Parameters:
        realZoom - the new real zoom value
        animate - whether to animate the transition
      • setMaxZoom

         abstract Unit setMaxZoom(Float maxZoom, Integer type)

        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.

        Parameters:
        maxZoom - the max zoom
        type - the constraint mode
      • setMinZoom

         abstract Unit setMinZoom(Float minZoom, Integer type)

        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.

        Parameters:
        minZoom - the min zoom
        type - the constraint mode
      • cancelAnimations

         abstract Boolean 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.

      • getZoom

         abstract Float getZoom()

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

        This can be different than the actual scale you get in the matrix, because at startup we apply a base zoom to respect the "center inside" policy. All zoom calls, including min zoom and max zoom, refer to this axis, where zoom is set to 1 right after the initial transformation.

      • getRealZoom

         abstract Float getRealZoom()

        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.

      • getPanX

         abstract Float getPanX()

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

      • getPanY

         abstract Float getPanY()

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

      • getScaledPan

         abstract ScaledPoint getScaledPan()

        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.

      • getScaledPanX

         abstract Float getScaledPanX()

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

      • getScaledPanY

         abstract Float getScaledPanY()

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