GithubHelp home page GithubHelp logo

av-shekhawat / zoomimageview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from k1slay/zoomimageview

0.0 0.0 0.0 5.8 MB

Android ImageView with support for zoom and pan

License: MIT License

Kotlin 100.00%

zoomimageview's Introduction

ZoomImageView

A custom ImageView Implementation

Supports

  • Double-tap to zoom
  • Pinch zoom
  • Drag to pan
  • Fling to pan
  • Swipe to dismiss

Double tap    Pinch to zoom   
Pan    Swipe to dismiss

Implementation

Extends the standard AppCompatImageView api with a few minor additions

Add to layout

<com.k2.zoomimageview.ZoomImageView
    android:id="@+id/iv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Drawable callback

imageView.onDrawableLoaded {
    // invoked when any image is loaded, like from a library like Glide, picasso or coil
    // can be used for updating progress UI
}

Get/Set zoom level

imageView.currentZoom = 1.5F // sets current zoom to 1.5 x
imageView.currentZoom // returns 1.5F

Reset pan and zoom

imageView.resetZoom()

Parent layout touch intercept

Allow/disallow parent viewgroup to intercept touch event while zoomed in. Panning and swiping in a parent like ViewPager can cause some issues with gesture detection

imageView.disallowPagingWhenZoomed = true

Debug information

Display drawable bounds and scale/translate info on the view. Can be useful when modifying/debugging the view

imageView.debugInfoVisible = true

Swipe to dismiss

Enable/Disable

imageView.swipeToDismissEnabled = true

Dismiss callback. For best results use shared activity/fragment transition

imageView.onDismiss = {
    finishAfterTransition() or finish()
}

Track swipe to dismiss progress. Can be used to update UI accordingly

dismissProgressListener = { progress ->
    bgView.alpha = 1.0f - progress
}

Planned improvements and future additions

  • Support for multiple scale types (only fit-center works for now)
  • Publish as a library (maybe)

Credits

Huge thanks to Chris Banes for his PhotoView library

Casey Horner for this photo on unsplash

Coil lib

License and usage

Feel free to use this file in your code. Just download and add to your project

zoomimageview's People

Contributors

k1slay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.