How can I make an Android seek-bar move smoothly?

前端 未结 5 1348
故里飘歌
故里飘歌 2021-02-04 11:05

I\'m trying to make a SeekBar move more smoothly than just jumping straight to the position. I\'m doing this as I\'ve got a SeekBar with 3 options for a slider-type implementati

5条回答
  •  别那么骄傲
    2021-02-04 11:41

    This works fine for me, quite simple and straight forward.

    if (currentPosition > 0) {
        ObjectAnimator animation = ObjectAnimator.ofInt(seekBar, "progress", currentPosition);
        animation.setDuration(400);
        animation.setInterpolator(new DecelerateInterpolator());
        animation.start();
    }
    

提交回复
热议问题