13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Progressbarの色を変わらない時の対処法

Last updated at Posted at 2017-03-20

Progressbarの色を変更したいときにちょっとハマったのでまとめておく。

試したこと

android:progressDrawable="@color/primary"
android:progressTintMode="src_in"
android:progressTint="@color/primary"

これらでは色が変わることはなかった。

解決法

最終的に下記で解決できた。

android:indeterminate="true"
android:indeterminateTintMode="src_in"
android:indeterminateTint="@color/primary"

java側からなら下記

ProgresBar progressBar = (ProgressBar)findViewById(R.id.view_progress);
progressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.SRC_IN);

なお、indeterminate不確定の、不定の、明確でない、漠然とした などの意味なのだけど、なぜこの名前になっているのかな。。。

参考

13
11
2

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
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?