I'm new to android development and I need to develop view with some specifications
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.
After long of searching about how to implement something like that, I finally found a repository on GitHub solving my issue you can find classes for doing that here
and way to use the classes is:
yourView.setOnTouchListener(new MultiTouchListener());
in this way you can scale, zoom in/out (by pinch) and rotate the view by pinch too.