package com.example.testzoom;import android.os.Bundle;import android.app.Activity;import android.view.MotionEvent;import android.view.View;import android.view.View.OnTouchListener;import android.widget.ImageView;import android.widget.RelativeLayout;import android.widget.RelativeLayout.LayoutParams;public class MainActivity extends Activity {// 被缩放的图片private ImageView imageView;private float lastDistance = -1;RelativeLayout root;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);imageView = (ImageView) findViewById(R.id.imageView1);root = (RelativeLayout) findViewById(R.id.root);// 设置触摸监听器root.setOnTouchListener(new OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {switch (event.getAction()) {case MotionEvent.ACTION_POINTER_DOWN:System.out.println("DOWN");break;case MotionEvent.ACTION_MOVE:System.out.println("MOVE");if (event.getPointerCount() > 1) {float offsetX = event.getX(0) - event.getX(1);float offsetY = event.getY(0) - event.getX(1);RelativeLayout.LayoutParams layoutparams = (LayoutParams) imageView.getLayoutParams();float curDistance = (float) Math.sqrt(offsetX * offsetX offsetY * offsetY);if (lastDistance < 0) {lastDistance = curDistance;} else {if (lastDistance - curDistance > 5) {layoutparams.width = (int) (0.9f * imageView.getWidth());layoutparams.height = (int) (0.9f * imageView.getHeight());} else if (curDistance - lastDistance > 5) {layoutparams.width = (int) (1.1f * imageView.getWidth());layoutparams.height = (int) (1.1f * imageView.getWidth());}lastDistance = curDistance;imageView.setLayoutParams(layoutparams);}}break;case MotionEvent.ACTION_UP:System.out.println("UP");break;default:break;}return true;}});}
推荐整理分享图片放大缩小(ps如何把图片放大缩小),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:图片放大缩小不变形,图片放大缩小怎么设置,图片放大缩小的快捷键,图片放大缩小怎么设置,ps如何把图片放大缩小,图片放大缩小软件,图片放大缩小怎么弄,ps如何把图片放大缩小,内容如对您有帮助,希望把文章链接给更多的朋友!
}
//感觉效果没有相册里面的图片放大缩小好
版权声明:本文为博主原创文章,未经博主允许不得转载。
javax.net.ssl.SSLException: hostname in certificate didnt match: 每个协议有自己的一套SSL东西,Android链接https经常会抛出如下错误javax.net.ssl.SSLException:hostnameincertificatedidntmatch:test.rigbee.cn!=rigbee.cnORrigbee.cnORwww.rigbee.cnato
如何控制 Android 控件的样式 如何控制Android控件的样式大家都知道,通过Android控件的样式是可以自定义的,像是TextView中的TextSize(文字大小),TextColor(文字颜色)等等,那么怎
Android线程间通讯的几种方式 1.runOnUiThread(Runnable)在子线程中直接使用该方法,可以更新UIrunOnUiThread(newRunnable(){//更新UI@Overridepublicvoidrun(){publish_time.setText(更新失败);}});2.View.postDelay(Run