Giter Site home page Giter Site logo

swipeimageview's Introduction

SwipeImageView

Swipe/zoom/pinch ImageView for Android.

How to include

Gradle

Add the JitPack repository in your root build.gradle at the end of repositories:

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

Then add the dependency in your app/build.gradle:

dependencies {
	implementation 'com.github.markusfisch:SwipeImageView:1.2.1'
}

Android Archive

Alternatively you may just download the latest aar from Releases and put it into app/libs in your app.

Then make sure your app/build.gradle contains the following line in the dependencies block:

dependencies {
	implementation fileTree(dir: 'libs', include: '*')
	...
}

How to use

Add it to a layout:

<de.markusfisch.android.swipeimageview.widget.SwipeImageView
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/swipe_view"
	android:layout_width="match_parent"
	android:layout_height="match_parent"/>

Or create it in java:

import de.markusfisch.android.swipeimageview.widget.SwipeImageView;

SwipeImageView swipeImageView = new SwipeImageView(context);

Then, set up the images to display from a Cursor:

swipeImageView.setImages(cursor, columnName, startIndex);

Make sure to always invoke SwipeImageView.closeCursor() to close the transferred cursor:

@Override
public void onDestroy() {
	super.onDestroy();
	swipeImageView.closeCursor();
}

If you don't have a Cursor for your image collection, you may simply use a MatrixCursor:

String columnName = "path";
cursor = new MatrixCursor(new String[]{columnName});
for (String path : paths) {
	cursor.addRow(new Object[]{path});
}
swipeImageView.setImages(cursor, columnName, index);

Make sure to call SwipeImageView.closeCursor() here too.

Demo

This is a demo app you may use to see and try if this widget is what you're searching for. Either import it into Android Studio or, if you're not on that thing from Redmond, just type make to build, install and run.

License

This widget is so basic, it should be Public Domain. And it is.

swipeimageview's People

Contributors

markusfisch 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.