Tyl*_*ler 41 android android-animation
现在我通过检查进度何时达到100来检测我的ValueAnimator的结束...
//Setup the animation
ValueAnimator anim = ValueAnimator.ofInt(progress, seekBar.getMax());
//Set the duration
anim.setDuration(Utility.setAnimationDuration(progress));
anim.addUpdateListener(new AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
int animProgress = (Integer) animation.getAnimatedValue();
if ( animProgress == 100)
{
//Done
}
else
{
seekBar.setProgress(animProgress);
}
}
});
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?我阅读了文档,但在完成时无法找到任何类型的监听器或回调.我试过使用,isRunning()但它没有用.
Fel*_*los 120
你可以这样做:
ValueAnimator anim = ValueAnimator.ofInt(progress, seekBar.getMax());
anim.setDuration(Utility.setAnimationDuration(progress));
anim.addUpdateListener(new AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
int animProgress = (Integer) animation.getAnimatedValue();
seekBar.setProgress(animProgress);
}
});
anim.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
// done
}
});
anim.start();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21261 次 |
| 最近记录: |