当前位置: 首页 > news >正文

正规营销型网站建设重庆哪家公司做网站好

正规营销型网站建设,重庆哪家公司做网站好,佰联轴承网做的网站,南宁seo产品优化服务1.android 触摸事件侦听 安卓的用户交互方式包括两种#xff0c;一种是点击交互#xff0c;一种是触摸交互。点击交互就是手指按下抬起一个动作组。而触摸交互分为按下#xff08;down#xff09;#xff0c;移动#xff08;move#xff09;#xff0c;抬起#xff08…1.android 触摸事件侦听 安卓的用户交互方式包括两种一种是点击交互一种是触摸交互。点击交互就是手指按下抬起一个动作组。而触摸交互分为按下down移动move抬起up。 触摸事件侦听代码输出触摸事件的三个动作 我们用一个framlayout布局进行操作 import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout;public class MainActivity extends AppCompatActivity {private FrameLayout container;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);container (FrameLayout) findViewById(R.id.container);container.setOnTouchListener(new View.OnTouchListener() {Overridepublic boolean onTouch(View view, MotionEvent motionEvent) {switch (motionEvent.getAction()){case MotionEvent.ACTION_DOWN:System.out.println(action:down);break;case MotionEvent.ACTION_MOVE:System.out.println(action:move);break;case MotionEvent.ACTION_UP:System.out.println(action:up);break;}return true; //remember to change this return to ture}});} } 注意记得把onTouch方法的返回值改成true。 运行结果 07-13 14:35:19.883 11720-11720/bhu.com.myapplication I/System.out: action:down 07-13 14:35:19.924 11720-11720/bhu.com.myapplication I/System.out: action:move 07-13 14:35:19.954 11720-11720/bhu.com.myapplication I/System.out: action:move 07-13 14:35:19.964 11720-11720/bhu.com.myapplication I/System.out: action:move 07-13 14:35:19.984 11720-11720/bhu.com.myapplication I/System.out: action:move 07-13 14:35:19.984 11720-11720/bhu.com.myapplication I/System.out: action:up 2.获取触摸的当前坐标 import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout;public class MainActivity extends AppCompatActivity {private FrameLayout container;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);container (FrameLayout) findViewById(R.id.container);container.setOnTouchListener(new View.OnTouchListener() {Overridepublic boolean onTouch(View view, MotionEvent motionEvent) {switch (motionEvent.getAction()){case MotionEvent.ACTION_DOWN:System.out.println(action:down);break;case MotionEvent.ACTION_MOVE:System.out.println(String.format((%f,%f),motionEvent.getX(),motionEvent.getY()));break;case MotionEvent.ACTION_UP:System.out.println(action:up);break;}return true; //remember to change this return to ture}});} } 输出结果 07-13 14:39:50.442 11720-11720/bhu.com.myapplication I/System.out: (366.251312,682.000000) 07-13 14:39:50.452 11720-11720/bhu.com.myapplication I/System.out: (367.076874,682.000000) 07-13 14:39:50.472 11720-11720/bhu.com.myapplication I/System.out: (367.000000,680.500000) 07-13 14:39:50.482 11720-11720/bhu.com.myapplication I/System.out: (368.067780,681.000000) 07-13 14:39:50.512 11720-11720/bhu.com.myapplication I/System.out: (369.000000,681.000000) 07-13 14:39:50.532 11720-11720/bhu.com.myapplication I/System.out: (370.142609,681.000000) 07-13 14:39:50.542 11720-11720/bhu.com.myapplication I/System.out: (371.500000,681.000000) 07-13 14:39:50.582 11720-11720/bhu.com.myapplication I/System.out: (373.497681,681.000000) 07-13 14:39:50.592 11720-11720/bhu.com.myapplication I/System.out: (374.960114,681.000000) 07-13 14:39:50.612 11720-11720/bhu.com.myapplication I/System.out: (376.413116,681.000000) 3.实现拖动控件 import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView;public class MainActivity extends AppCompatActivity {private FrameLayout container;private ImageView imv;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);container (FrameLayout) findViewById(R.id.container);imv (ImageView) findViewById(R.id.imv);container.setOnTouchListener(new View.OnTouchListener() {Overridepublic boolean onTouch(View view, MotionEvent motionEvent) {switch (motionEvent.getAction()){case MotionEvent.ACTION_DOWN:System.out.println(action:down);break;case MotionEvent.ACTION_MOVE://System.out.println(String.format((%f,%f),motionEvent.getX(),motionEvent.getY()));FrameLayout.LayoutParams lp (FrameLayout.LayoutParams) imv.getLayoutParams();lp.leftMargin (int) motionEvent.getX();lp.topMargin (int) motionEvent.getY();imv.setLayoutParams(lp);break;case MotionEvent.ACTION_UP:System.out.println(action:up);break;}return true; //remember to change this return to ture}});} } 运行结果 该图片无法显示 4.获取多个触控点的坐标 import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView;public class MainActivity extends AppCompatActivity {private FrameLayout container;private ImageView imv;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);container (FrameLayout) findViewById(R.id.container);imv (ImageView) findViewById(R.id.imv);container.setOnTouchListener(new View.OnTouchListener() {Overridepublic boolean onTouch(View view, MotionEvent motionEvent) {switch (motionEvent.getAction()){case MotionEvent.ACTION_DOWN:System.out.println(action:down);break;case MotionEvent.ACTION_MOVE://System.out.println(String.format((%f,%f),motionEvent.getX(),motionEvent.getY()));System.out.println(pointers count:motionEvent.getPointerCount()); //get the number of pointers System.out.println(String.format(point1:(%f,%f) point2:(%f,%f),motionEvent.getX(0),motionEvent.getY(0),motionEvent.getX(1),motionEvent.getY(1)));//when you put just one finger on the screen,there will be a exception,because there is not a getX(1).break;case MotionEvent.ACTION_UP:System.out.println(action:up);break;}return true; //remember to change this return to ture}});} 输出结果 07-13 14:54:52.855 5804-5804/bhu.com.myapplication I/System.out: point1:(245.296295,718.407410) point2:(456.000000,389.000000) 07-13 14:54:52.865 5804-5804/bhu.com.myapplication I/System.out: pointers count:2 07-13 14:54:52.865 5804-5804/bhu.com.myapplication I/System.out: point1:(244.000000,721.000000) point2:(455.000000,392.000000) 07-13 14:54:52.885 5804-5804/bhu.com.myapplication I/System.out: pointers count:2 07-13 14:54:52.885 5804-5804/bhu.com.myapplication I/System.out: point1:(242.387100,722.612915) point2:(454.000000,394.000000) 07-13 14:54:52.895 5804-5804/bhu.com.myapplication I/System.out: pointers count:2 07-13 14:54:52.905 5804-5804/bhu.com.myapplication I/System.out: point1:(242.000000,724.000000) point2:(453.000000,396.000000) 07-13 14:54:52.915 5804-5804/bhu.com.myapplication I/System.out: pointers count:2 07-13 14:54:52.915 5804-5804/bhu.com.myapplication I/System.out: point1:(241.000000,724.000000) point2:(452.000000,397.000000) 07-13 14:54:52.935 5804-5804/bhu.com.myapplication I/System.out: pointers count:2 07-13 14:54:52.935 5804-5804/bhu.com.myapplication I/System.out: point1:(241.000000,725.000000) point2:(452.000000,397.000000) 5.根据手势动作实现图片的缩放两点触控并且可以拖动 import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView;import com.google.android.gms.appindexing.Action; import com.google.android.gms.appindexing.AppIndex; import com.google.android.gms.common.api.GoogleApiClient;public class MainActivity extends AppCompatActivity {private FrameLayout container;private ImageView imv;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);container (FrameLayout) findViewById(R.id.container);imv (ImageView) findViewById(R.id.imv);container.setOnTouchListener(new View.OnTouchListener() {float cureentDistance;float lastDistance -1; //the distance of two point can not be a minus,when the distance is -1 ,it means its a initial value. Overridepublic boolean onTouch(View view, MotionEvent motionEvent) {switch (motionEvent.getAction()) {case MotionEvent.ACTION_DOWN:System.out.println(action:down);break;case MotionEvent.ACTION_MOVE:if (motionEvent.getPointerCount() 2) {//there must be two finger on the screenfloat offsetX motionEvent.getX(0) - motionEvent.getX(1);float offsetY motionEvent.getY(1) - motionEvent.getY(1);cureentDistance (float) Math.sqrt(offsetX * offsetX offsetY * offsetY);if (lastDistance 0) {lastDistance cureentDistance;} else {if (cureentDistance - lastDistance 5) {System.out.println(Zoom in);FrameLayout.LayoutParams lp (FrameLayout.LayoutParams) imv.getLayoutParams();lp.width (int) (1.1f*imv.getWidth());lp.height (int) (1.1f*imv.getHeight());imv.setLayoutParams(lp);lastDistance cureentDistance;} else if (lastDistance - cureentDistance 5) {System.out.println(Zoom out);FrameLayout.LayoutParams lp (FrameLayout.LayoutParams) imv.getLayoutParams();lp.width (int) (0.9f*imv.getWidth());lp.height (int) (0.9f*imv.getHeight());imv.setLayoutParams(lp);lastDistance cureentDistance;}}}else{FrameLayout.LayoutParams lp (FrameLayout.LayoutParams) imv.getLayoutParams();lp.leftMargin (int) (motionEvent.getX()-(imv.getWidth()/2));lp.topMargin (int) (motionEvent.getY()-(imv.getHeight()/2));imv.setLayoutParams(lp);}break;case MotionEvent.ACTION_UP:System.out.println(action:up);break;}return true; //remember to change this return to ture}});}}  转载于:https://www.cnblogs.com/androidNot/p/5667051.html
http://www.zqtcl.cn/news/539345/

相关文章:

  • 做足球直播网站wordpress筛选框
  • 做网站需求文档深圳站建在边境
  • 网站建设法规浙江建设信息港证书查询
  • 影视作品网站开发与设计网站建设教程简笔画
  • 自己可以给公司做网站吗网站建设 用ftp上传文件
  • 电子商务网站开发与管理网站建设的设备
  • 网站建设项目公司沈阳网站关键字优化
  • 可以做淘宝联盟的免费网站优质国外网站
  • 石家庄营销型网站建设公司服装公司网站源码
  • 网站开发的软硬件需求做网站盘锦
  • 创意网站建设排行榜python和php哪个做网站
  • 开锁做网站怎么样榆林网站开发公司
  • 松原市建设局网站苏州网站建设-中国互联
  • 标书制作教程视频网站福田祥菱v1单排
  • 点网站出图片怎么做能看人与动物做的网站
  • 免费开源建站系统源码wordpress公共函数在哪里
  • 西昌市建设工程管理局网站模块化网站开发
  • 无限看片的视频大全免费下载上海网络优化方法
  • 物流公司做网站注重什么问题中国建设银行征信中心网站
  • 教务处网站建设专业做鞋子的网站吗
  • 梦幻创意网站建设成都做网站设计哪家便宜
  • 织梦网站栏目修改教程丝绸之路网站建设意义
  • 如何知道一个网站是谁做的北京装饰公司前十名
  • 杭州网站建设哪个平台好visualstudio 做网站
  • 广州站是哪个站h5建站系统
  • 网站首页网址应该有对应的域名南京高端模板建站
  • 自己做的网站竞价优化怎么做网站流量赚钱吗
  • 人力资源网站建设mip网站模板
  • 太原市住房和城乡建设部网站网站 备案 换空间
  • 怎么做网站备份网站运营数据周报表怎么做