Bug: 72524823

Clone this repo:
  1. ba09fe2 Add METADATA to subsampling-scale-image-view: Apache2=NOTICE am: a329cb4bcb by Bob Badour · 3 months ago master android-r-beta-2 android-r-beta-3
  2. a329cb4 Add METADATA to subsampling-scale-image-view: Apache2=NOTICE by Bob Badour · 3 months ago
  3. 5fb46aa [automerger skipped] DO NOT MERGE am: 5ffef6ff20 -s ours am: 75a004caa3 -s ours by Xin Li · 1 year, 8 months ago android10-c2f2-release android10-c2f2-s1-release android10-c2f2-s2-release android10-dev android10-mainline-media-release android10-mainline-networking-release android10-mainline-resolv-release android10-mainline-tzdata-release android10-qpr1-b-release android10-qpr1-b-s1-release android10-qpr1-c-release android10-qpr1-c-s1-release android10-qpr1-d-release android10-qpr1-mainline-release android10-qpr1-release android10-qpr2-release android10-qpr2-s1-release android10-qpr2-s2-release android10-qpr2-s3-release android10-qpr2-s4-release android10-qpr3-release android10-qpr3-s1-release ndk-sysroot-r21 android-10.0.0_r12 android-10.0.0_r13 android-10.0.0_r14 android-10.0.0_r15 android-10.0.0_r16 android-10.0.0_r18 android-10.0.0_r19 android-10.0.0_r20 android-10.0.0_r21 android-10.0.0_r22 android-10.0.0_r23 android-10.0.0_r24 android-10.0.0_r25 android-10.0.0_r26 android-10.0.0_r27 android-10.0.0_r28 android-10.0.0_r29 android-10.0.0_r30 android-10.0.0_r31 android-10.0.0_r32 android-10.0.0_r33 android-10.0.0_r34 android-10.0.0_r35 android-10.0.0_r36 android-10.0.0_r37 android-10.0.0_r38 android-10.0.0_r39 android-10.0.0_r40 android-10.0.0_r41 android-10.0.0_r7 android-10.0.0_r8 android-10.0.0_r9 android-mainline-10.0.0_r10 android-mainline-10.0.0_r11 android-mainline-10.0.0_r4 android-mainline-10.0.0_r5 android-mainline-10.0.0_r6 android-mainline-10.0.0_r7 android-mainline-10.0.0_r8 android-mainline-10.0.0_r9 android-r-preview-1 android-r-preview-2 android-r-preview-3 android-r-preview-4
  4. 4a9a0dc [automerger skipped] DO NOT MERGE am: 5ffef6ff20 -s ours by Xin Li · 1 year, 8 months ago
  5. 75a004c [automerger skipped] DO NOT MERGE am: 5ffef6ff20 -s ours by Xin Li · 1 year, 8 months ago

Subsampling Scale Image View

Build Status

A custom image view for Android, designed for photo galleries and displaying huge images (e.g. maps and building plans) without OutOfMemoryErrors. Includes pinch to zoom, panning, rotation and animation support, and allows easy extension so you can add your own overlays and touch event detection.

The view optionally uses subsampling and tiles to support very large images - a low resolution base layer is loaded and as you zoom in, it is overlaid with smaller high resolution tiles for the visible area. This avoids holding too much data in memory. It's ideal for displaying large images while allowing you to zoom in to the high resolution details. You can disable tiling for smaller images and when displaying a bitmap object. There are some advantages and disadvantages to disabling tiling so to decide which is best, see the wiki.


Migration guides

Versions 3.9.0, 3.8.0 and 3.0.0 contain breaking changes. Migration instructions can be found in the wiki.

Download the sample app

Get it on Google Play

Kotlin Sample App on GitHub




Image display

  • Display images from assets, resources, the file system or bitmaps
  • Automatically rotate images from the file system (e.g. the camera or gallery) according to EXIF
  • Manually rotate images in 90° increments
  • Display a region of the source image
  • Use a preview image while large images load
  • Swap images at runtime
  • Use a custom bitmap decoder

With tiling enabled:

  • Display huge images, larger than can be loaded into memory
  • Show high resolution detail on zooming in
  • Tested up to 20,000x20,000px, though larger images are slower

Gesture detection

  • One finger pan
  • Two finger pinch to zoom
  • Quick scale (one finger zoom)
  • Pan while zooming
  • Seamless switch between pan and zoom
  • Fling momentum after panning
  • Double tap to zoom in and out
  • Options to disable pan and/or zoom gestures


  • Public methods for animating the scale and center
  • Customisable duration and easing
  • Optional uninterruptible animations

Overridable event detection

  • Supports OnClickListener and OnLongClickListener
  • Supports interception of events using GestureDetector and OnTouchListener
  • Extend to add your own gestures

Easy integration

  • Use within a ViewPager to create a photo gallery
  • Easily restore scale, center and orientation after screen rotation
  • Can be extended to add overlay graphics that move and scale with the image
  • Handles view resizing and wrap_content layout

Quick start

1) Add com.davemorrissey.labs:subsampling-scale-image-view:3.9.0 as a dependency in your build.gradle file.

2) Add the view to your layout XML.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent" >



3a) Now, in your fragment or activity, set the image resource, asset name or file path.

SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(id.imageView);
// ... or ...
// ... or ...

3b) Or, if you have a Bitmap object in memory, load it into the view. This is unsuitable for large images because it bypasses subsampling - you may get an OutOfMemoryError.

SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(id.imageView);

Photo credits


Copyright 2018 David Morrissey, and licensed under the Apache License, Version 2.0. No attribution is necessary but it's very much appreciated. Star this project if you like it!