0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RoundCornerProgressBarの実装方法

0
Posted at

Android で進捗バーや棒グラフを実装したいときにRoundCornerProgressBarを使用します。使い方をメモします。

Gradleに依存関係を追加します。

implementation "com.akexorcist:RoundCornerProgressBar:x.x.x"

レイアウトをXML配置します。

<com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar
    android:id="@+id/progressBar"
    android:layout_width="match_parent"
    android:layout_height="20dp"
    android:layout_margin="16dp"
    app:rcMax="100"
    app:rcProgress="30"
    app:rcRadius="999dp"
    app:rcProgressColor="#3F51B5"
    app:rcBackgroundColor="#E0E0E0" />
  • rcMax → 最大値
  • rcProgress → 最大値(100)に対しての現在の値
  • rcRadius → 角丸の半径

Kotlin から進捗を更新する

RoundCornerProgressBarはFloat型です。

binding.progressBar.max = 100f
binding.progressBar.progress = 50f

アニメーションを付ける

ObjectAnimator を使う方法です。実装をシンプルにかけます。

ObjectAnimator.ofFloat(
    progressBar,
    "progress",
    progressBar.progress,
    80f
).apply {
    duration = 500
    start()
}
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?