Android通过手势实现的缩放处理
01 import android.app.Activity;
02 import android.content.Context;
03 import android.graphics.Canvas;
04 import android.graphics.Color;
05 import android.graphics.Paint;
06 import android.os.Bundle;
07 import android.util.DisplayMetrics;
08 import android.view.MotionEvent;
09 import android.view.View;
10
11 /**
12 * ...
13 *
14 * @author vlinux
15 *
16 */
17 public class MultiTouchTestActivity extends Activity {
18 /** Called when the activity is first created. */
19 @Override
20 public void onCreate(Bundle savedInstanceState) {
21 super.onCreate(savedInstanceState);
22 // setContentView(R.layout.main);
23 View view = new MultiTouchView(this);
24 setContentView(view);
25 }
26
27 class MultiTouchView extends View {
28
29 private float x1;
30 private float y1;
31 private float x2;
32 private float y2;
33
34 public MultiTouchView(Context context) {
35 super(context);
36 // TODO Auto-generated constructor stub
37 }
38
39 @Override
40 public boolean onTouchEvent(MotionEvent event) {
41 // TODO Auto-generated method stub
42
43 float size = event.getSize();
44
45 int szi = (int) size;
46 int dxi = szi >> 12;
47 int dyit = ((1 << 12) - 1);
48 int dyi = szi & dyit;
49
50 DisplayMetrics metrics = getResources().getDisplayMetrics();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>