2011-10-27 8 views
1

たとえば、シークバーを100に移動すると、imageViewを1秒以内に100degに回転させます。問題は、すぐに50に移動して100にジャンプし、50にゆっくりと移動する場合です。 現在の位置から回転する方法はありますか?またはランダムな度合いのアニメーションをスムーズにするためのより洗練されたソリューションですか?スムーズローテーション

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

答えて

0

私はこの質問がかなり前に投稿されたことを知っていますが、私は同じ問題で苦労して解決策を思いつきました。ローパスフィルターと呼ばれるフィルターを使用する必要があります。これは、ノイズの一部、およびセンサから戻って来る「外れ値」の値を除外します。 thisを見てください。