This is a simple Android View class which provides basic pinch-zoom capability for images.
- Pinch zoom in place (i.e. zoom occurs from point of touch)
- Panning
- Double tap reset
- Configurable zoom boundaries (min/max)
- Does not support Fling
- Does not support Rotation
- Does not support Pan and Zoom together
- Only supports Bitmap objects and image resources (i.e. does not support setting a Drawable that is not a bitmap/png/jpg)
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"/>
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); } }