我有一个用XML定义的复合动画:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="1200"/>
<alpha
android:duration="1200"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
我正在像这样开始动画:
Animation animation = AnimationUtils.loadAnimation( itemView.getContext(), R.anim.animation );
myView.setAnimation( animation );
到目前为止,一切都很好。现在,我通过以下方式添加SeekBar:
final SeekBar seek=(SeekBar) findViewById(R.id.seekBar1);
seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
// animation.setStartOffset( progress );
// animation.pause/stop();
}
}
我要完成的工作:
-The animation should be paused/static.
-It is only animated **during** onProgressChanged
-OnProgressChanged provides a value from 0 to 100 (for example) which would tell animation at which offset to set the animation playhead at and pause. (ex. 0% would be beginning of the animation or 100% would be the end of animation)
如何做到这一点的正确方法是什么?我打算使用感官输入,而不是使用SeekView,因此对动画偏移的更新将非常频繁。动画中是否有单一方法或我可以使用的其他技术?谢谢!