• Stars
    star
    18,771
  • Rank 1,386 (Top 0.03 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

PhotoView

PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView.

[

Dependency

Add this in your root build.gradle file (not your module build.gradle file):

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

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

Then, add the library to your module build.gradle

dependencies {
    implementation 'com.github.chrisbanes:PhotoView:latest.release.here'
}

Features

  • Out of the box zooming, using multi-touch and double-tap.
  • Scrolling, with smooth scrolling fling.
  • Works perfectly when used in a scrolling parent (such as ViewPager).
  • Allows the application to be notified when the displayed Matrix has changed. Useful for when you need to update your UI based on the current zoom/scroll position.
  • Allows the application to be notified when the user taps on the Photo.

Usage

There is a sample provided which shows how to use the library in a more advanced way, but for completeness, here is all that is required to get PhotoView working:

<com.github.chrisbanes.photoview.PhotoView
    android:id="@+id/photo_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);

That's it!

Issues With ViewGroups

There are some ViewGroups (ones that utilize onInterceptTouchEvent) that throw exceptions when a PhotoView is placed within them, most notably ViewPager and DrawerLayout. This is a framework issue that has not been resolved. In order to prevent this exception (which typically occurs when you zoom out), take a look at HackyDrawerLayout and you can see the solution is to simply catch the exception. Any ViewGroup which uses onInterceptTouchEvent will also need to be extended and exceptions caught. Use the HackyDrawerLayout as a template of how to do so. The basic implementation is:

public class HackyProblematicViewGroup extends ProblematicViewGroup {

    public HackyProblematicViewGroup(Context context) {
        super(context);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        try {
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException e) {
						//uncomment if you really want to see these errors
            //e.printStackTrace();
            return false;
        }
    }
}

Usage with Fresco

Due to the complex nature of Fresco, this library does not currently support Fresco. See this project as an alternative solution.

Subsampling Support

This library aims to keep the zooming implementation simple. If you are looking for an implementation that supports subsampling, check out this project

License

Copyright 2018 Chris Banes

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.

More Repositories

1

flutter_cached_network_image

Download, cache and show images in a flutter app
Dart
2,426
star
2

flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
Dart
2,020
star
3

flutter-geolocator

Android and iOS Geolocation plugin for Flutter
Dart
1,239
star
4

LottieXamarin

Render After Effects animations natively on Android, iOS, MacOS and TvOS for Xamarin
C#
1,218
star
5

XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
C#
766
star
6

flutter_cache_manager

Generic cache manager for flutter
Dart
749
star
7

XF-Material-Library

A Xamarin Forms library for implementing Material Design
C#
647
star
8

octo_image

A multifunctional Flutter image widget
Dart
156
star
9

ExoPlayerXamarin

Xamarin bindings library for the Google ExoPlayer library
C#
153
star
10

Chameleon

Chameleon is a flexible media player build with Xamarin.Forms
C#
152
star
11

flutter-geocoding

A Geocoding plugin for Flutter
Dart
135
star
12

Xamarin-Sidebar

A slideout navigation control for Xamarin.iOS
C#
113
star
13

screenrecorder

Flutter package which can be used to record flutter widgets
Dart
64
star
14

FoldingCell

FoldingCell is an expanding content cell inspired by folding paper material
C#
55
star
15

flutter-permission-plugins

This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.
Dart
52
star
16

MvxForms

Sample App with Xamarin.Forms and MvvmCross
C#
47
star
17

HugoStructuredData

Collection of structured data snippets in Google preferred JSON-LD format, with support for Hugo
HTML
42
star
18

flutter-contacts-plugin

Contact plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to read, create and update contacts from the address book.
Dart
40
star
19

NavigationTabBarXamarin

Navigation tab bar with colorful interactions for Xamarin Android
C#
39
star
20

InfiniteCycleViewPagerXamarin

Infinite cycle ViewPager with two-way orientation and interactive effect.
C#
36
star
21

XamarinItemTouchHelper

Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView for Xamarin
C#
36
star
22

VlcXamarin

Xamarin.Android bindings for VLC player
C#
34
star
23

flutter-google-api-availability

Check the availability of Google Play services on the current device
Dart
34
star
24

NavigationTabStripXamarin

Navigation tab strip with smooth interaction
C#
24
star
25

FantasySlideXamarin

Another sliding menu base on DrawerLayout
C#
20
star
26

DiagonalLayoutXamarin

With Diagonal Layout explore new styles and approaches on material design
C#
19
star
27

LoaderViewXamarin

Library that enables TextView of ImageView to show loading animation while waiting for the text and image get loaded
C#
17
star
28

flutter-video-bloc

Dart
16
star
29

flutter_wizard

A library that makes it easy for you to create your own custom wizard.
Dart
16
star
30

FloatingNavigationView

A simple Floating Action Button that shows an anchored Navigation View
C#
16
star
31

flutter-essentials

Essential cross platform APIs for your Flutter apps
Dart
16
star
32

MaterialDesignHelpers

Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library.
C#
13
star
33

GuardedActions

A library to increase the error handling, testability and reusability for all your MVVM driven apps!
C#
13
star
34

HoverXamarin

A floating menu library for Xamarin Android.
C#
12
star
35

FlipShareXamarin

It's a flip way to show share widget.
C#
11
star
36

AndroidSlidingUpPanelXamarin

This library provides a simple way to add a draggable sliding up panel to your Android app
C#
11
star
37

byteplot

A Dart command-line tool for Flutter to make your life easier
Dart
10
star
38

FFmpegMediaMetadataRetrieverXamarin

FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
C#
10
star
39

full-stack-on-rust

Source code and documentation for our 'full stack on rust' meetup on 29-9-2022
Rust
8
star
40

InteractiveMediaAdsXamarin

IMA Android SDK v3 for Xamarin
C#
8
star
41

AutoLinkTextViewXamarin

AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks.
C#
8
star
42

GoogleVRXamarin

Xamarin bindings library for the Google VR library
C#
8
star
43

cheat-sheets

This repo contains a set of cheat sheets often used by the Baseflow crew.
8
star
44

flutter-blues

Flutter plugin to provide easy access to platform specific Bluetooth low energy services
Dart
7
star
45

flutter_swipe_detector

A Flutter package to detect your swipe directions and provides you with callbacks to handle them.
Dart
7
star
46

flutter_uwb

A Flutter plugin for working with Ultra Wide Band sensors.
Dart
7
star
47

stellar-rust-sdk

Welcome to the Rust Stellar SDK repository! This project aims to empower developers with a robust Rust SDK for the Stellar cryptocurrency network. Leverage Rust's performance and security advantages to build efficient and scalable applications on Stellar. Join us in shaping the future of blockchain development with Stellar and Rust integration.
Rust
7
star
48

WaveSideBarXamarin

An Index Side Bar With Wave Effect
C#
6
star
49

baseflow_plugin_template

Template for the Baseflow flutter plugins
Dart
5
star
50

VerticalViewPagerXamarin

Vertically ViewPager and vertically transformer for Xamarin Android
C#
5
star
51

flutter_state_management_demo

A demonstration app showcasing the Baseflow way of State Management in Flutter
Dart
4
star
52

AutoscaleEditTextXamarin

AutoscaleEditText bindings for Xamarin Android
C#
4
star
53

flutter-style-guide

A Flutter style-guide example app
Dart
3
star
54

DSTV.Net

A basic Tekla DSTV NC file parser written in C#
C#
3
star
55

flutter-meetup

Sheets and samples for our flutter meetups
Dart
3
star
56

konami_detector

A package to detect your konami codes and executes the provided callbacks.
Dart
3
star
57

terraform-demo

Code and descriptions for the demo on the 14th July 2023
HCL
2
star
58

service_manager

A Flutter plugin to manage the state of platform specific services (e.g. location services).
Dart
2
star
59

flutter_ioc

A standard interface providing inversion of control services to Dart or Flutter applications.
Dart
2
star
60

EllipsizeTextViewXamarin

The EllipsizeTextView extends TextView, support omit (Ellipsize/Ellipsis) redundant characters in multiple lines situtation.
C#
2
star
61

GuardedActions.Samples

Contains sample project on how to implement the GuardedActions package.
C#
1
star