I'm new to android development and I need to develop view with some specifications
- move by touch
- scale by pinch (zoom in\out)
- rotation using two fingures
I've developed rotation by using these steps here but there are some issues like jumping view if one finger removed suddenly.
and for move used this code it works well but think it is issue in sudden movement.
public static View.OnTouchListener getTouchListener(){
View.OnTouchListener onTouchListener = new View.OnTouchListener() {
int prevX, prevY;
@Override
public boolean onTouch(View v, MotionEvent event) {
final ConstraintLayout.LayoutParams par = (ConstraintLayout.LayoutParams) v.getLayoutParams();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
v.bringToFront();
prevX = (int) event.getRawX();
prevY = (int) event.getRawY();
par.bottomMargin = -8 * v.getHeight();
par.rightMargin = -8 * v.getWidth();
v.setLayoutParams(par);
return true;
}
case MotionEvent.ACTION_MOVE: {
par.topMargin += (int) event.getRawY() - prevY;
prevY = (int) event.getRawY();
par.leftMargin += (int) event.getRawX() - prevX;
prevX = (int) event.getRawX();
v.setLayoutParams(par);
return true;
}
}
return false;
}
};
return onTouchListener;
}
I need someone help me to get the three features together without any issues Hint: if there is library it is welcomed.