LoginSignup
31
34

More than 5 years have passed since last update.

AndroidのProgressBarの進捗をなめらかにする

Posted at

普通の方法

private ProgressBar progressBar;
.
.
.
// 進捗が変わった時に呼び出される
private void onHogeProgressChanged(int progressInPercent){
    progressBar.setProgress(progressInPercent);
}

これだと進捗が変わるたびに、カクカクとバーの長さが変わっちゃいます。
UX的によくない感じなのでもっとスムーズに変わらんものかとggってみました。

Android: make a progress bar update smoothly
http://stackoverflow.com/questions/6097795/android-make-a-progress-bar-update-smoothly

スムーズな方法

private void onHogeProgressChanged(int progressInPercent){
    ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", progressInPercent);
    animation.setDuration(500); // 0.5 second
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();
}

さすがはStackOverflowさんやわ〜。

31
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
34