package com.example.zoom02;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ZoomControls;
 
public class MainActivity extends Activity {
 
    ZoomControls zoom;
    ImageView img;
    LinearLayout ll;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        zoom = new ZoomControls(this);
        img = new ImageView(this);
        ll = new LinearLayout(this);
        img.setBackgroundResource(R.drawable.ic_launcher);
 
        ll.setOrientation(LinearLayout.VERTICAL);
        
        ll.addView(img);
        ll.addView(zoom);
        setContentView(ll);
 
        zoom.setOnZoomInClickListener(new OnClickListener() {
 
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
 
                float x = img.getScaleX();
                float y = img.getScaleY();
 
                img.setScaleX((float) (x + 1));
                img.setScaleY((float) (y + 1));
            }
        });
 
        zoom.setOnZoomOutClickListener(new View.OnClickListener() {
 
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
 
                float x = img.getScaleX();
                float y = img.getScaleY();
 
                img.setScaleX((float) (x - 1));
                img.setScaleY((float) (y - 1));
            }
        });
    }
}
