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) {}
});