我正在尝试此代码
https://stackoverflow.com/a/14297097/1907593
效果很好,但在ACTION_UP上没有任何反应, 我希望在ACTION_UP上将图像重置为初始视图(不旋转)
答案 0 :(得分:1)
采取行动:
case MotionEvent.ACTION_UP : {
mPrevAngle = mCurrAngle = 0;
animate(mPrevAngle, mCurrAngle,0);
break;
}
答案 1 :(得分:1)
我用这段代码解决了
private double mCurrAngle = 0;
private double mPrevAngle = 0;
private long durationMillis;
case MotionEvent.ACTION_UP : {
mPrevAngle = Math.toDegrees(Math.atan2(x - xc, yc - y));
mCurrAngle = 0;
durationMillis = 1000;
animate(mPrevAngle, mCurrAngle,durationMillis);
break;
case MotionEvent.ACTION_MOVE: {
mPrevAngle = mCurrAngle;
mCurrAngle = Math.toDegrees(Math.atan2(x - xc, yc - y));
animate(mPrevAngle, mCurrAngle, 0);
if (mCurrAngle>0);{mCurrAngle = mCurrAngle-360;}
break;
现在的问题是myCurrAngle的度数值不是0到-360,而是从0到180,从-1到-180。我试图用上面的代码转换为0-360值,但现在我的值从-180到-360,从-360到-540。我的最终目标是当我使用ACTION_MOVE达到-240°时自动返回0°(ACTION_UP代码)