Pal*_*i g 6 animation android seekbar
我是android的新手.我试图为水平搜索栏设置动画但是无法做到这一点.我只想要一个动画,其中搜索栏在一段时间内显示进度,比如1分钟.有人可以建议/提供想法/代码片段,我该如何设置标准搜索栏的动画?
我应该使用像objectanimator或valueAnimation这样的动画?我是否需要定义一个运行方法(不确定!)来为拇指设置动画以进入下一个位置?
提前致谢.
Zel*_*ion 13
一种方法是使用ValueAnimator:
final SeekBar seekBar = findViewById(R.id.seekBar);
ValueAnimator anim = ValueAnimator.ofInt(0,seekBar.getMax());
anim.setDuration(1000);
anim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int animProgress = (Integer) animation.getAnimatedValue();
seekBar.setProgress(animProgress);
}
});
Run Code Online (Sandbox Code Playgroud)
另一种方式可能是(没有测试这个):
final SeekBar seekBar = findViewById(R.id.seekBar);
ObjectAnimator anim = ObjectAnimator.ofFloat(seekBar, "progress", 0,seekBar.getMax());
anim.setDuration(10000);
anim.start();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7605 次 |
| 最近记录: |