【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/

更多相关文章

  1. Android 经典示例,初学者的绝好源码资料
  2. Android控件之CheckBox(复选框控件)
  3. androidの布局控件居于最底部实现
  4. android的EditText控件,内容右对齐
  5. SystemUI源码分析
  6. android复合控件
  7. android开源新闻小程序、3D翻转公告效果、小说检索、Kotlin开发T
  8. Android 自定义控件打造史上最简单的侧滑菜单

随机推荐

  1. 六种最具视觉效果的Android(安卓)手机浏
  2. Android XMPP Service (Google Talk) + G
  3. 实现android图像识别的几种方法
  4. Android之——jni通用工具方法
  5. adb 发送文件到Android设备和从Android手
  6. Android Menu详解及示例代码
  7. Android中Snackbar的介绍以及使用
  8. Android系统启动流程(三)解析SyetemServer
  9. 极客学院Android视频分享
  10. Eclipse 配置 NDK