Android实现图片放大缩小--中国移动开发者社区
Android实现图片放大缩小 -- 未审核 编辑文档package com.min.Test_Gallery;
import Android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.Matrix; import android.os.Bundle; import android.util.DisplayMetrics; import android.util.Log;
import android.view.GestureDetector; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View;
import android.view.GestureDetector.OnGestureListener; import android.view.View.OnTouchListener; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.Toast;
public class DisplayImage extends Activity implements OnTouchListener, OnGestureListener {
private static final String TAG = \ private static final int FLING_MIN_DISTANCE = 100; private static final int FLING_MIN_VELOCITY = 200;
/* 相关变量声明 */
private ImageView mImageView; private Button mButton01; private Button mButton02; private FrameLayout layout1; private LinearLayout layoutImage; private Bitmap bmp; private int id=0; private int displayWidth; private int displayHeight; private float scaleWidth=1; private float scaleHeight=1;
private GestureDetector mGestureDetector;
/** Called when the activity is first created. */ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); /* 加载display.xml Layout */ setContentView(R.layout.display);
/* 取得屏幕分辨率大小 */
DisplayMetrics dm=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm); displayWidth=dm.widthPixels; displayHeight=dm.heightPixels;
/* 初始化相关变量 */
Bundle bundle = this.getIntent().getExtras(); Integer imageId = bundle.getInt(\ Log.i(TAG, \