Irurueta Android Gesture Bitmap View
| This documentation was generated with the assistance of AI. Please report any inaccuracies. |
irurueta-android-gesture-bitmap-view is an Android library that provides GestureBitmapView, a custom
android.view.View that displays a bitmap and lets the user translate (scroll), scale (zoom) and rotate it with
touch gestures.
Features
-
Display any
BitmaporDrawable, either from code or with theapp:srcXML attribute. -
Nine initial display types (
DisplayType) that decide how the bitmap is first fitted into the view, such asFIT_X_CENTER(the default),FIT_IF_BIGGERorCENTER_CROP. -
Scroll with one finger, with two fingers, or with two fingers only.
-
Pinch to zoom, with configurable minimum and maximum scale.
-
Double tap to jump in scale at the tapped location.
-
Rotate with two fingers around the point between them.
-
Fling, with an animated scroll.
-
Rotation fling: a rotation that ends while still rotating keeps going, decelerating until it stops.
-
Bounce effects: configurable margins let the bitmap go past the scale and scroll limits while the gesture lasts, and it animates back into place when the fingers are lifted. Dragging past a scroll limit is progressively slowed down (tension), up to the margin.
-
Listeners for bounds reached, minimum and maximum scale reached, animation completion and double taps.
-
Programmatic access to the current transformation as a
Matrixor asMetricTransformationParameters(scale, rotation angle and translation). -
View state (transformation, gesture flags, display type, scale and scroll settings) survives configuration changes through
onSaveInstanceState/onRestoreInstanceState.
Core concepts
The bitmap is drawn with a single display matrix that is the composition of two transformations:
-
The base transformation (
baseTransformationMatrix,baseTransformationParameters) is computed from the bitmap size, the view size anddisplayType. It is recomputed when the bitmap, the display type or the view size changes. -
The transformation (
transformationMatrix,transformationParameters) holds the scale, rotation and translation that gestures have applied on top of the base transformation.minScaleandmaxScalelimit the scale of this transformation, so a scale of1.0means "as initially displayed". -
The display transformation (
displayTransformationMatrix,displayTransformationParameters) is the product of both and maps bitmap pixels to view pixels.displayRectis the rectangle the bitmap currently occupies in the view.
All of them are metric (similarity) transformations: a uniform scale , a rotation angle in radians and a translation , represented as the 3x3 matrix
MetricTransformationParameters converts between this matrix form and its four parameters.
Public API at a glance
| Type | Purpose |
|---|---|
|
The view. Displays the bitmap, handles the gestures and exposes the configuration properties and listeners. |
|
How the bitmap is initially fitted into the view. |
|
Listener interfaces for the events raised by the view (see Listeners). |
|
Detects two-finger rotation gestures. Used internally by the view, and usable on its own. |
|
Scale, rotation angle and translation of a 2D metric transformation, convertible to and from an
|
|
Thrown when a matrix does not represent a valid metric transformation. |
Where to go next
-
Installation: add the dependency to your project.
-
Usage: add the view to a layout and control it from code.
-
Gestures: what each gesture does and how to enable or tune it.
-
Configuration reference: every property, XML attribute and default value.
-
Reference: API documentation and other links.