import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.FloatMath;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.GridView;
import android.widget.ImageView;
public class FlipperDemo2 extends Activity implements OnTouchListener {
 private static final String TAG = "Touch";
 private static final float MIN_ZOOM = 1.0f;
 private static final float MAX_ZOOM = 5.0f; 
Matrix matrix = new Matrix(); Matrix savedMatrix = new Matrix(); 
static final int NONE = 0;
static final int DRAG = 1;
static final int ZOOM = 2; int mode = NONE; 
PointF start = new PointF();
PointF mid = new PointF();
float oldDist = 1f; 
public void onCreate(Bundle savedInstanceState) { 
 super.onCreate(savedInstanceState);  
 setContentView(R.layout.main);  
 ImageView view = (ImageView) findViewById(R.id.picture1); 
   view.setScaleType(ImageView.ScaleType.FIT_CENTER);
   view.setOnTouchListener(this);    } 
public boolean onTouch(View v, MotionEvent event) {  
 ImageView view = (ImageView) v;  
 view.setScaleType(ImageView.ScaleType.MATRIX);   
 float scale;         dumpEvent(event);  
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:    
     savedMatrix.set(matrix);    
     start.set(event.getX(), event.getY());  
     Log.d(TAG, "mode=DRAG" );    
     mode = DRAG;       break; 
     case MotionEvent.ACTION_UP:    case MotionEvent.ACTION_POINTER_UP:
         mode = NONE;  
         Log.d(TAG, "mode=NONE" ); 
         break;    case MotionEvent.ACTION_POINTER_DOWN:
              oldDist = spacing(event); 
              Log.d(TAG, "oldDist=" + oldDist);   
              if (oldDist > 5f) {       
               savedMatrix.set(matrix);      
               midPoint(mid, event);    
               mode = ZOOM;        
               Log.d(TAG, "mode=ZOOM" );       }   
              break;     case MotionEvent.ACTION_MOVE:     
               if (mode == DRAG) {         
                matrix.set(savedMatrix);     
                if (view.getLeft() >= -392){         
                 matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);          }       }  
               else if (mode == ZOOM) {
                float newDist = spacing(event);    
                Log.d(TAG, "newDist=" + newDist);    
                if (newDist > 5f) {       
                 matrix.set(savedMatrix);   
                 scale = newDist / oldDist;
                       
                 matrix.postScale(scale, scale, mid.x, mid.y);          }       }  
               break;    }  
  view.setImageMatrix(matrix);  
  return true; }
private float spacing(MotionEvent event) { 
 float x = event.getX(0) - event.getX(1); 
 float y = event.getY(0) - event.getY(1); 
 return FloatMath.sqrt(x * x + y * y); }
private void midPoint(PointF point, MotionEvent event) { 
 float x = event.getX(0) + event.getX(1);   
 float y = event.getY(0) + event.getY(1);  
 point.set(x / 2, y / 2); }
 private void dumpEvent(MotionEvent event) {  
  String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,       "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; 
  StringBuilder sb = new StringBuilder();
  int action = event.getAction(); 
  int actionCode = action & MotionEvent.ACTION_MASK;
  sb.append("event ACTION_" ).append(names[actionCode]);
  if (actionCode == MotionEvent.ACTION_POINTER_DOWN          || actionCode == MotionEvent.ACTION_POINTER_UP) {
   sb.append("(pid " ).append(       action >> MotionEvent.ACTION_POINTER_ID_SHIFT); 
   sb.append(")" );    }    sb.append("[" );  
   for (int i = 0; i < event.getPointerCount(); i++) {
    sb.append("#" ).append(i);    
    sb.append("(pid " ).append(event.getPointerId(i));
    sb.append(")=" ).append((int) event.getX(i));  
    sb.append("," ).append((int) event.getY(i)); 
    if (i + 1 < event.getPointerCount())          sb.append(";" );    }
   sb.append("]" );    Log.d(TAG, sb.toString()); 
              
             
 }}
             

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
  android:layout_width="fill_parent"
     android:layout_height="wrap_content">

  <Button android:id="@+id/prev_btn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="◀이전 페이지"/>
  <Button android:id="@+id/next_btn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="다음 페이지▶"/>
 </LinearLayout>

    <LinearLayout
     android:background="#303030"
  android:layout_width="fill_parent"
     android:layout_height="fill_parent">

     <ViewFlipper android:id="@+id/ViewFlipper1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
      
      <com.androidside.FlipperDemo.touch.java
      
       android:id="@+id/picture1"
      
android:layout_height="fill_parent"
 android:layout_width="fill_parent"

 android:layout_marginTop="5px"
 android:scaleType="matrix"


 
 android:src="@drawable/t3" /> 
            
     </ViewFlipper>
 </LinearLayout>

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.androidside.FlipperDemo"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".FlipperDemo2"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="7" />
</manifest>

 

실행을 해보면  실행이 안된다고 나오네요 ㅜㅜ 이미지뷰 대신 com.androidside.FlipperDemo.touch.java
로 바꿔줘도 안되네요 ..뭐가 문젠가요??