How can I change the button’s positon with my cursor moving.
I mean how to let the button follow the cursor as I move the button.
How can I change the button’s positon with my cursor moving. I mean how
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
try to implement on touch listener.
new View.OnTouchListener() { private float downX = 0; private float downY = 0;@Overridepublic boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case (MotionEvent.ACTION_DOWN):
this.downX = motionEvent.getX();
this.downY = motionEvent.getY();
break;
case MotionEvent.ACTION_MOVE:
final View btn= layout.findViewById(R.id.button);
currentView.layout(newLeft,
newTop, newRight,
newBottom));
break;
}
return true;
}
}