[英]canvas controlling by ontouchlistener
I made a two small rectangle by using canvas but i faced a small problem . 我用帆布制作了一个两个小矩形,但我遇到了一个小问题。 I don't know how to control the two rectangles by onTouchlistener and move it vertically and horizontally .
我不知道如何通过onTouchlistener控制两个矩形并垂直和水平移动它。
any suggestion ? 有什么建议吗?
You should try something like this: 你应该尝试这样的事情:
private final class MyTouchListener implements OnTouchListener {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
ClipData data = ClipData.newPlainText("", "");
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
view.setVisibility(View.INVISIBLE);
return true;
} else {
return false;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.