J'ai un cercle que je veux faire pivoter. J'utilise SimpleOnGestureListener pour gérer les gestes, en particulier la méthode onScroll.rotation lisse android en utilisant SimpleOnGestureListener
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
float lWidth = e1.getX() - centeralPointX;
float lHeight = e1.getY() - centeralPointY;
float lRadius = FloatMath.sqrt(lWidth * lWidth + lHeight * lHeight);
if ((lRadius <= bigCircleRadius) && (lRadius >= smallCircleRadius)) {
mLastAngle = (float) (Math.atan(lHeight/lWidth) * 180/Math.PI)
+ step/2;
float currWidth = e2.getX() - centeralPointX;
float currHeight = e2.getY() - centeralPointY;
mCurrentAngle = (float) (Math.atan(currHeight/currWidth) * 180/Math.PI)
+ step/2;
mAngle = mLastAngle - mCurrentAngle;
mLastAngle = mCurrentAngle;
// show angles
TextView lastANGLE, endANGLE, ANGLE;
lastANGLE = (TextView) findViewById(R.id.currentAngle);
lastANGLE.setText("last " + mLastAngle);
endANGLE = (TextView) findViewById(R.id.endAngle);
ANGLE = (TextView) findViewById(R.id.angle);
endANGLE.setText("current " + mCurrentAngle);
ANGLE.setText("ANGLE " + mAngle);
rotation = (float) (-mAngle - step/2);
if (rotate != null && !rotate.hasEnded()) {
rotate.cancel();
rotate.reset();
}
rotate = RotateCircle(radius, radius);
words_layout.startAnimation(rotate);
return true;
} else
return false;
}
Mais cela ne fonctionne pas correctement. Je veux que ce cercle tourne doucement, mais ce n'est pas le cas. Comment puis-je faire cela? J'ai essayé d'utiliser la méthode onFling mais elle tourne mon cercle après la fin du mouvement. Mais j'ai besoin de le faire pivoter pendant le mouvement.