android多点触摸缩放图片

android多点触摸缩放图片

ID:12458461

大小:43.50 KB

页数:16页

时间:2018-07-17

android多点触摸缩放图片_第1页
android多点触摸缩放图片_第2页
android多点触摸缩放图片_第3页
android多点触摸缩放图片_第4页
android多点触摸缩放图片_第5页
资源描述:

《android多点触摸缩放图片》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Android多点触摸缩放图片importandroid.view.MotionEvent; importandroid.view.animation.AccelerateInterpolator; importandroid.view.animation.Animation; importandroid.view.animation.Animation.AnimationListener; importandroid.view.animation.ScaleAnimation; importandro

2、id.widget.ImageView; /**** *这里你要明白几个方法执行的流程:首先ImageView是继承自View的子类. *onLayout方法:是一个回调方法.该方法会在在View中的layout方法中执行,在执行layout方法前面会首先执行setFrame方法. *layout方法: *setFrame方法:判断我们的View是否发生变化,如果发生变化,那么将最新的l,t,r,b传递给View,然后刷新进行动态更新UI. *并且返回ture.没有变化返回false. *invalid

3、ate方法:用于刷新当前控件, publicclassDragImageViewextendsImageView{ privateActivitymActivity; privateintscreen_W,screen_H;//可见屏幕的宽高度 privateintbitmap_W,bitmap_H;//当前图片宽高 privateintMAX_W,MAX_H,MIN_W,MIN_H;//极限值 privateintcurrent_Top,current_Right,current_Bottom,cur

4、rent_Left;//当前图片上下左右坐标 privateintstart_Top=-1,start_Right=-1,start_Bottom=-1, start_Left=-1;//初始化默认位置. privateintstart_x,start_y,current_x,current_y;//触摸位置 privatefloatbeforeLenght,afterLenght;//两触点距离 privatefloatscale_temp;//缩放比例 /** *模式NONE:无DRAG:拖拽.ZO

5、OM:缩放 *@authorzhangjia privateenumMODE{ NONE,DRAG,ZOOM privateMODEmode=MODE.NONE;//默认模式 privatebooleanisControl_V=false;//垂直监控 privatebooleanisControl_H=false;//水平监控 privateScaleAnimationscaleAnimation;//缩放动画 privatebooleanisScaleAnim=false;//缩放动画 privat

6、eMyAsyncTaskmyAsyncTask;//异步动画 /**构造方法**/ publicDragImageView(Contextcontext){ super(context); publicvoidsetmActivity(ActivitymActivity){ this.mActivity=mActivity; /**可见屏幕宽度**/ publicvoidsetScreen_W(intscreen_W){ this.screen_W=screen_W; /**可见屏幕高度**/ publ

7、icvoidsetScreen_H(intscreen_H){ this.screen_H=screen_H; publicDragImageView(Contextcontext,AttributeSetattrs){ super(context,attrs); /*** *设置显示图片 @Override publicvoidsetImageBitmap(Bitmapbm){ super.setImageBitmap(bm); /**获取图片宽高**/ bitmap_W=bm.getWidth();

8、 bitmap_H=bm.getHeight(); MAX_W=bitmap_W*3; MAX_H=bitmap_H*3; MIN_W=bitmap_W/2; MIN_H=bitmap_H/2; @Override protectedvoidonLayout(booleanchanged,intleft,inttop,intright, intbottom){ super.onLayout(changed,left,top,right,bo

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。