Sample app

This documentation was generated with the assistance of AI. Please report any inaccuracies.

The repository’s app/ module is a minimal application (com.irurueta.android.gesturebitmap.app) that depends on the lib module through implementation(project(":lib")). It shows the simplest possible integration: a single activity whose layout contains a full-screen GestureBitmapView with all settings left at their defaults. The demo animation on the overview page was recorded with it.

Layout

app/src/main/res/layout/activity_main.xml:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.irurueta.android.gesturebitmap.GestureBitmapView
        android:id="@+id/gesture_bitmap"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:src="@drawable/image"/>

</androidx.constraintlayout.widget.ConstraintLayout>

The image comes from app/src/main/res/drawable-nodpi/image.jpeg (4032x3024) through app:src, so no Kotlin code is needed to set it. Since it is a raster resource, it is decoded by regions automatically: a preview is shown first, and sharper levels and patches are decoded as you zoom in (see Large images). regionDecodingEnabled, hardwareBitmapsEnabled and cachedLevelsMemoryBudget are left at their defaults. The sample does not include a draw mode; see Updating image contents for one.

Activity

app/src/main/java/com/irurueta/android/gesturebitmap/app/MainActivity.kt:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        supportActionBar?.hide()
        setContentView(R.layout.activity_main)
    }
}

Running it

Connect a device or start an emulator (API 26 or later), then from the repository root:

./gradlew :app:installDebug

or open the project in Android Studio and run the app configuration. Try dragging, flinging, pinching, double tapping and rotating with two fingers; see Gestures for what each one does.

To experiment with other settings, add attributes from the XML attributes table to the layout, for example app:displayType="center_crop" or app:rotationEnabled="false", or the large image attributes app:regionDecodingEnabled, app:hardwareBitmapsEnabled and app:cachedLevelsMemoryBudget.