Skip to content

Instantly share code, notes, and snippets.

@klaaspieter
Created June 30, 2014 18:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaaspieter/26f1eaf55d519454e94d to your computer and use it in GitHub Desktop.
Save klaaspieter/26f1eaf55d519454e94d to your computer and use it in GitHub Desktop.
Android ProgressBar subclass with a custom foreground color
package com.yourkarma.android.ui.components;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
public class ProgressBar extends android.widget.ProgressBar {
public ProgressBar(Context context) {
super(context);
init();
}
public ProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
Drawable drawable = getIndeterminateDrawable();
if (drawable != null) {
drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment