【Android源码分享】 android 控件的移动
16lz
2021-01-23
【Android源码分享】 android 控件的移动的源代码分享
1、java代码
imagebutton.setOnTouchListener(newOnTouchListener(){int[]postion=newint[]{0,0};@OverridepublicbooleanonTouch(Viewv,MotionEventevent){intx=(int)event.getRawX();inty=(int)event.getRawY();intleft=v.getLeft();inttop=v.getTop();switch(event.getAction()){caseMotionEvent.ACTION_DOWN:postion[0]=(int)event.getX();postion[1]=y-v.getTop();break;caseMotionEvent.ACTION_MOVE:v.layout(x-postion[0],y-postion[1],x+1024-postion[0],y-postion[1]+768);v.postInvalidate();default:break;}returnfalse;}});
2、布局移动
x=x+10;y=y+10;LayoutParamslayoutParams=mIconPinpu.getLayoutParams();layoutParams.height=x;layoutParams.width=y;mIconPinpu.setLayoutParams(layoutParams);
以上就是关于Android控件移动的源码分享,更多关于Android源码分享资源,请访问:
http://www.eoeandroid.com/
更多相关文章
- Android 经典示例,初学者的绝好源码资料
- Android控件之CheckBox(复选框控件)
- androidの布局控件居于最底部实现
- android的EditText控件,内容右对齐
- SystemUI源码分析
- android复合控件
- android开源新闻小程序、3D翻转公告效果、小说检索、Kotlin开发T
- Android 自定义控件打造史上最简单的侧滑菜单