package com.example.zoom03;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ZoomControls;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ZoomControls;
 
@SuppressLint("NewApi")
public class MainActivity extends Activity {
  
 String imagefile ="/mnt/sdcard/recu.jpg";
 ZoomControls zoom;
 ImageView image;
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         
        zoom = (ZoomControls) findViewById(R.id.zoomControls1);
        
        image = (ImageView)findViewById(R.id.image);
        Bitmap bm = BitmapFactory.decodeFile(imagefile);
        image.setImageBitmap(bm);
        
        
        zoom.setOnZoomInClickListener(new OnClickListener() {
			
    		@SuppressLint("NewApi")
			@Override
    		public void onClick(View v) {
    			// TODO Auto-generated method stub
    			
    			float x = image.getScaleX();
    			float y = image.getScaleY();
    			
    			image.setScaleX((float) (x+1));
    			image.setScaleY((float) (y+1));
    		}
    	});
     
            zoom.setOnZoomOutClickListener(new View.OnClickListener() {
    			
    		@Override
    		public void onClick(View v) {
    			// TODO Auto-generated method stub
    			
     
    			float x = image.getScaleX();
    			float y = image.getScaleY();
    			
    			image.setScaleX((float) (x-1));
    			image.setScaleY((float) (y-1));
    		}
    	});
        
    }
    
    
}
