Android - Tinting ProgressBar on pre-Lollipop devices -
my app's minimum api-level 19 (kitkat), , contains layout horizontal progressbar
. i'm using android:progresstint
attribute tint bar custom color. works pretty on lollipop (api 21) , above, below (for example on api 19) doesn't; shows in different color. reason attribute
is used in api level 21 , higher
as android studio states.
so i'm wondering can alternative tinting progressbar
on pre-lollipop devices, too. can made inside layout file xml? or should done on different way?
edit #1: progressbar used show concrete values in percents, not indicating layout loading. want make clear because after trying kuldeep kulkarni wrote below, bar looked material loading indicator (of course on lollipop device, not visible result on kitkat device).
you can wrap progressbar indeterminatedrawable
method pre-lollipop
.
if (build.version.sdk_int < build.version_codes.lollipop) { drawable drawableprogress = drawablecompat.wrap(progressbar.getindeterminatedrawable()); drawablecompat.settint(drawableprogress, contextcompat.getcolor(getcontext(), android.r.color.holo_green_light)); progressbar.setindeterminatedrawable(drawablecompat.unwrap(drawableprogress)); } else { progressbar.getindeterminatedrawable().setcolorfilter(contextcompat.getcolor(getcontext(), android.r.color.holo_green_light), porterduff.mode.src_in); }
Comments
Post a Comment