标签:tle getc top 获取 str get string ima bottom
public boolean onTouch(View view, MotionEvent motionEvent) { if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){ //记录按下时的数据 sx = (int) motionEvent.getRawX(); sy = (int) motionEvent.getRawY(); origin_l = view.getLeft(); origin_r = view.getRight(); origin_b = view.getBottom(); origin_t = view.getTop(); } else if(motionEvent.getAction() == MotionEvent.ACTION_UP){ // Log.d(TAG, "onTouch: UP"); // 得到imageView最开始的各顶点的坐标 Toast.makeText(getContext(),String.valueOf(sx)+","+String.valueOf(sy),Toast.LENGTH_SHORT).show(); view.layout(origin_l,origin_t,origin_r,origin_b); } else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){ int x = (int) motionEvent.getRawX(); int y = (int) motionEvent.getRawY(); // 获取手指移动的距离 int dx = x - sx; int dy = y - sy; // 得到imageView最开始的各顶点的坐标 int l = view.getLeft(); int r = view.getRight(); int t = view.getTop(); int b = view.getBottom(); // 更改imageView在窗体的位置 view.layout(l + dx, t + dy, r + dx, b + dy); // 获取移动后的位置 sx = (int) motionEvent.getRawX(); sy = (int) motionEvent.getRawY(); } return true; }
标签:tle getc top 获取 str get string ima bottom
原文地址:https://www.cnblogs.com/zhaozilongcjiajia/p/10764030.html