Created
June 30, 2014 18:58
-
-
Save klaaspieter/26f1eaf55d519454e94d to your computer and use it in GitHub Desktop.
Android ProgressBar subclass with a custom foreground color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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