Image Zoom In Out Example In Android |Android App Development With AndroidCource

Monday 28 August 2017

Image Zoom In Out Example In Android

Add This Library on build.gradle

compile 'com.bogdwellers:pinchtozoom:0.1'

MainActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.bhaumik.imagezoominoutdemo.MainActivity">

    <ImageView
        android:id="@+id/image_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/m9"/>

</RelativeLayout>
MainActivity.java

package com.example.bhaumik.imagezoominoutdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.bogdwellers.pinchtozoom.ImageMatrixTouchHandler;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ImageView imageView = (ImageView) findViewById(R.id.image_view);
        imageView.setOnTouchListener(new ImageMatrixTouchHandler(MainActivity.this));

    }
}

0 comments:

Post a Comment