Convert Figma logo to code with AI

stfalcon-studio logoStfalconImageViewer

A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures

1,990
252
1,990
54

Top Related Projects

Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

18,764

Implementation of ImageView for Android that supports zooming, by various touch gestures.

Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.

Adds touch functionality to Android ImageView.

Quick Overview

StfalconImageViewer is an Android library for displaying images in a full-screen viewer with smooth transitions and gesture controls. It supports zooming, panning, and swiping between multiple images, providing a seamless and interactive image viewing experience for Android applications.

Pros

  • Smooth transitions and animations for a polished user experience
  • Supports zooming, panning, and swiping gestures
  • Easy integration with existing Android projects
  • Customizable UI elements and behaviors

Cons

  • Limited to Android platform only
  • May require additional setup for complex image loading scenarios
  • Documentation could be more comprehensive
  • Some reported issues with memory management in certain scenarios

Code Examples

  1. Basic usage with a single image:
val imageView = findViewById<ImageView>(R.id.image)
imageView.setOnClickListener {
    StfalconImageViewer.Builder<String>(this, listOf(imageUrl)) { view, image ->
        Glide.with(this).load(image).into(view)
    }.show()
}
  1. Using with multiple images:
val images = listOf("url1", "url2", "url3")
StfalconImageViewer.Builder<String>(this, images) { view, image ->
    Glide.with(this).load(image).into(view)
}.show()
  1. Customizing the viewer:
StfalconImageViewer.Builder<String>(this, images) { view, image ->
    Glide.with(this).load(image).into(view)
}
.withTransitionFrom(imageView)
.withHiddenStatusBar(false)
.withOverlayView(customOverlayView)
.withBackgroundColor(Color.BLACK)
.allowZooming(true)
.allowSwipeToDismiss(true)
.show()

Getting Started

  1. Add the dependency to your app's build.gradle:
dependencies {
    implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
}
  1. Initialize the viewer in your activity or fragment:
val images = listOf("url1", "url2", "url3")
StfalconImageViewer.Builder<String>(this, images) { view, image ->
    Glide.with(this).load(image).into(view)
}.show()
  1. Customize the viewer as needed using the available builder methods.

Competitor Comparisons

Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

Pros of FrescoImageViewer

  • Built on top of Fresco library, providing efficient image loading and caching
  • Supports animated GIFs and WebP images
  • Offers more advanced image processing capabilities

Cons of FrescoImageViewer

  • Larger library size due to Fresco dependency
  • Potentially more complex setup and configuration
  • Limited to Android platform only

Code Comparison

StfalconImageViewer:

StfalconImageViewer.Builder<String>(this, images) { imageView, image ->
    Glide.with(this).load(image).into(imageView)
}.show()

FrescoImageViewer:

ImageViewer.Builder(this, images)
    .setStartPosition(startPosition)
    .setOnImageChangeListener { position -> }
    .show()

Both libraries offer similar ease of use for basic image viewing functionality. However, FrescoImageViewer requires additional setup for the Fresco library, while StfalconImageViewer is more flexible with image loading libraries.

StfalconImageViewer is a lightweight, versatile option suitable for simple image viewing needs across multiple platforms. FrescoImageViewer, on the other hand, leverages Fresco's powerful features for more advanced image handling requirements on Android.

Choose StfalconImageViewer for simplicity and cross-platform support, or FrescoImageViewer for advanced image processing capabilities on Android projects.

18,764

Implementation of ImageView for Android that supports zooming, by various touch gestures.

Pros of PhotoView

  • More mature and widely adopted project with a larger community
  • Supports a broader range of image types and formats
  • Offers more customization options for zooming and panning behavior

Cons of PhotoView

  • Heavier library with a larger footprint
  • Less frequent updates and maintenance compared to StfalconImageViewer
  • May require more setup and configuration for basic use cases

Code Comparison

StfalconImageViewer:

StfalconImageViewer.Builder<String>(this, images) { imageView, image ->
    Glide.with(this).load(image).into(imageView)
}.show()

PhotoView:

val photoView = PhotoView(context)
Glide.with(this).load(imageUrl).into(photoView)
layout.addView(photoView)

Both libraries offer simple integration, but StfalconImageViewer provides a more streamlined API for displaying images in a gallery-like viewer. PhotoView focuses on enhancing individual ImageView widgets with zoom and pan capabilities, requiring more manual setup for a full-screen gallery experience.

Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.

Pros of subsampling-scale-image-view

  • Supports very large images (over 100MP) through efficient subsampling and tiling
  • Offers smooth pan and zoom functionality with configurable max/min scale
  • Provides extensive customization options for image display and behavior

Cons of subsampling-scale-image-view

  • Limited to single image viewing, unlike StfalconImageViewer's gallery support
  • Lacks built-in transition animations between images or view states
  • More complex implementation due to advanced features and customization options

Code Comparison

subsampling-scale-image-view:

SubsamplingScaleImageView imageView = new SubsamplingScaleImageView(context);
imageView.setImage(ImageSource.uri("/sdcard/image.jpg"));
imageView.setMaxScale(10f);

StfalconImageViewer:

StfalconImageViewer.Builder<String>(this, images) { view, image ->
    Glide.with(this).load(image).into(view)
}.show()

Summary

subsampling-scale-image-view excels in handling large images with smooth pan and zoom capabilities, making it ideal for applications requiring detailed image exploration. However, it's more focused on single image viewing and requires more setup.

StfalconImageViewer offers a simpler implementation for image galleries with built-in transitions, but may not handle extremely large images as efficiently. The choice between the two depends on specific project requirements, such as image sizes and gallery functionality needs.

Adds touch functionality to Android ImageView.

Pros of TouchImageView

  • Longer development history and more mature codebase
  • Supports additional features like double-tap zooming and scrolling
  • Extensive documentation and usage examples

Cons of TouchImageView

  • Limited to single image viewing
  • Lacks built-in image loading and caching mechanisms
  • No out-of-the-box support for transitions or animations

Code Comparison

TouchImageView:

TouchImageView imageView = new TouchImageView(this);
imageView.setImageResource(R.drawable.image);
imageView.setMaxZoom(4f);

StfalconImageViewer:

StfalconImageViewer.Builder<String>(this, images) { view, image ->
    Glide.with(this).load(image).into(view)
}.show()

TouchImageView focuses on enhancing a single ImageView with touch capabilities, while StfalconImageViewer provides a full-fledged image viewer with multiple image support and built-in transitions. TouchImageView offers more granular control over zoom and touch behavior, making it suitable for integrating into custom layouts. StfalconImageViewer, on the other hand, provides a quick and easy solution for implementing a complete image viewing experience with minimal setup.

Both libraries have their strengths, and the choice between them depends on the specific requirements of your project. TouchImageView is ideal for scenarios where you need detailed control over a single image view, while StfalconImageViewer is better suited for creating a gallery-like experience with multiple images and smooth transitions.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

codebeat badge Codacy Badge Download License

Stfalcon ImageViewer

A simple and customizable full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures. Compatible with all of the most popular image processing libraries such as Picasso, Glide etc. Based on PhotoView by chrisbanes.

alt tag alt tag

Who we are

Need iOS and Android apps, MVP development or prototyping? Contact us via info@stfalcon.com. We develop software since 2009, and we're known experts in this field. Check out our portfolio and see more libraries from stfalcon-studio.

Requirements

  • A project configured with the AndroidX
  • SDK 19 and and higher

Demo Application

Get it on Google Play

Install

Download via Gradle:

Add this to the project build.gradle file:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

And then add the dependency to the module build.gradle file:

implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'

Download via Maven:

<dependency>
  <groupId>com.github.stfalcon</groupId>
  <artifactId>stfalcon-imageviewer</artifactId>
  <version>latest_version</version>
  <type>pom</type>
</dependency>

Where the latest_version is the value from Download badge.

Usage

Simple usage

All you need to show the viewer is to pass the context, list or array of your image objects and the implementation of the ImageLoader and call the show() method:

StfalconImageViewer.Builder<Image>(context, images) { view, image ->
    Picasso.get().load(image.url).into(view)
}.show()

Piece of cake!

Transition animation

To improve the UX of your app you would like to add a transition when a user opens the viewer. And this is simple as never before! Just tell the viewer which image should be used for animation using withTransitionFrom(myImageView) method and the library will do it for you!

If you need more advanced behavior like updating transition target while changing images in the viewer please see the sample app for how to do this.

Update images list on the fly

There are a lot of common cases (such as pagination, deleting, editing etc.) where you need to update the existing images list while the viewer is running. To do this you can simply update the existing list (or even replace it with a new one) and then call updateImages(images).

Change current image

Images are not always leafed through by the user. Maybe you want to implement some kind of preview list at the bottom of the viewer - setCurrentPosition is here for help. Change images programmatically wherever you want!

Custom overlay view

If you need to show some content over the image (e.g. sharing or download button, description, numeration etc.) you can set your own custom view using the setOverlayView(customView) and bind it with the viewer through the ImageViewer.OnImageChangeListener.

Background

Use the setBackgroundColorRes(colorRes) or setBackgroundColor(colorInt) to set a color of the fading background.

Images margin

Simply add margins between images using the withImagesMargin(context, dimenRes) method for dimensions, or use the withImageMarginPixels(int) for pixels size.

Container padding

Overlay image hides part of the images? Set container padding with dimens using withContainerPadding(context, start, top, end, bottom) or withContainerPadding(context, dimen) for all of the sides evenly. For setting a padding in pixels, just use the withContainerPadding(...) methods variant.

Status bar visibility

Control the status bar visibility of the opened viewer by using the withHiddenStatusBar(boolean) method (true by default)

Gestures

If you need to disable some of the gestures - you can use the allowSwipeToDismiss(boolean) and allowZooming(boolean) methods accordingly.

Options overview

Here is the example with all of the existing options applied:

StfalconImageViewer.Builder<String>(this, images, ::loadImage)
            .withStartPosition(startPosition)
            .withBackgroundColor(color)
            //.withBackgroundColorResource(R.color.color)
            .withOverlayView(view)
            .withImagesMargin(R.dimen.margin)
            //.withImageMarginPixels(margin)
            .withContainerPadding(R.dimen.padding)
            //.withContainerPadding(R.dimen.paddingStart, R.dimen.paddingTop, R.dimen.paddingEnd, R.dimen.paddingBottom)
            //.withContainerPaddingPixels(padding)
            //.withContainerPaddingPixels(paddingStart, paddingTop, paddingEnd, paddingBottom)
            .withHiddenStatusBar(shouldHideStatusBar)
            .allowZooming(isZoomingAllowed)
            .allowSwipeToDismiss(isSwipeToDismissAllowed)
            .withTransitionFrom(targeImageView)
            .withImageChangeListener(::onImageChanged)
            .withDismissListener(::onViewerDismissed)
            .withDismissListener(::onViewerDismissed)

Also, you can take a look at the sample project for more information.

Usage with Fresco

If you use the Fresco library - check out the FrescoImageViewer which was also developed by our team.

License

Copyright (C) 2018 stfalcon.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.