Skip to content

Instantly share code, notes, and snippets.

@hrules6872
Created July 22, 2016 08:01
Show Gist options
  • Save hrules6872/6bfaf5285b7fc53d55e517e10a4b02b4 to your computer and use it in GitHub Desktop.
Save hrules6872/6bfaf5285b7fc53d55e517e10a4b02b4 to your computer and use it in GitHub Desktop.
TintedProgressBar
public class TintedProgressBar extends ProgressBar {
public TintedProgressBar(Context context) {
this(context, null);
}
public TintedProgressBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TintedProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TintedProgressBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
private void init(Context context) {
getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(context, R.color.colorAccent),
PorterDuff.Mode.SRC_IN);
getProgressDrawable().setColorFilter(ContextCompat.getColor(context, R.color.colorAccent), PorterDuff.Mode.SRC_IN);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment