【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. 使用navigator.userAgent.toLowerCase()判断移动端类型
  2. SystemUI源码分析
  3. 使用navigator.userAgent.toLowerCase()判断移动端类型
  4. Android(安卓)拖拽效果实现代码分享 - ORIETech
  5. Android(安卓)Bitmap移动游戏背景
  6. ubuntu10.04系统android开发环境配置
  7. android开源新闻小程序、3D翻转公告效果、小说检索、Kotlin开发T
  8. Android电话拨打流程源码分析
  9. Android电话拨打流程源码分析

随机推荐

  1. android 发送带附件的邮件
  2. cordova 插件 开发添加 android 权限
  3. android中AlertDialog包含EditText时弹出
  4. 安卓startActivity:彻底理解startActivity
  5. android重启代码
  6. Android 基础面试题
  7. Android 源码目录结构
  8. Android中XML解析-Dom解析
  9. ANDROID笔记:TextView的简单使用
  10. 【翻译】安卓新播放器EXOplayer介绍