1
例如,如果我将seekbar移动到100,我希望imageView在一秒内旋转到100deg。问题是如果我马上将它移动到50,它会跳到100,然后慢慢移动到50. 有没有办法将它从当前位置旋转...或者更适合这些随机度的更平滑动画的优雅解决方案?Smooth rotation
seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
arrow2 = (ImageView) findViewById(R.id.imageView1);
seekBar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
public void onProgressChanged(SeekBar seekBar1, int progress, boolean fromUser)
{
currentSpeed.setText(""+progress);
RotateAnimation rotateAnimation = new RotateAnimation(fromPosition ,progress,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setDuration(1000);
rotateAnimation.setFillAfter(true);
arrow2.startAnimation(rotateAnimation);
fromPosition=progress;
}
public void onStartTrackingTouch(SeekBar seekSize1) {}
public void onStopTrackingTouch(SeekBar seekSize1) {}
});