Skip to content

Implements pinch-zoom, rotate, pan as an ImageView for Android 2.1+

Notifications You must be signed in to change notification settings

textagroup/gesture-imageview

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GestureImageView

This is a simple Android View class which provides basic pinch-zoom capability for images.

Features:

  1. Pinch zoom in place (i.e. zoom occurs from point of touch)
  2. Panning
  3. Double tap reset
  4. Configurable zoom boundaries (min/max)

Limitations:

  1. Does not support Fling
  2. Does not support Rotation
  3. Does not support Pan and Zoom together
  4. Only supports Bitmap objects and image resources (i.e. does not support setting a Drawable that is not a bitmap/png/jpg)

Usage

Configured as View in layout.xml

code:

<com.polites.android.GestureImageView
    android:id="@+id/image"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    gesture-image:min-scale="0.1"
    gesture-image:max-scale="10.0"
    android:src="@drawable/image"/>

Configured Programmatically

code:

import com.polites.android.GestureImageView;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout.LayoutParams;

public class SampleActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        GestureImageView view = new GestureImageView(this);
        view.setImageResource(R.drawable.image);
        view.setLayoutParams(params);

        ViewGroup layout = (ViewGroup) findViewById(R.id.layout);

        layout.addView(view);
    }
}

License

Apache License 2.0

About

Implements pinch-zoom, rotate, pan as an ImageView for Android 2.1+

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published