static-progress-bar
static-progress-bar copied to clipboard
Color Gradient
I love this class. I think it's so awesome and is my favorite progress bar so far. Few things:
- [ ]
getColor()
is deprecated. ReplacegetResources().getColor(
withContextCompat.getColor(getContext(),
in lines 75&76.
- Is there a way to introduce a color gradient to the Progress Bar so that the further the progress the stronger the progress bar's color becomes?
I thought about introducing a drawable layer-list like this but wasn't sure if I could do it since we're extending from a textView:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/Color">
<shape>
<corners android:radius="5dip" />
<gradient
android:angle="0"
android:centerColor="@color/amber_500"
android:centerY="0.5"
android:endColor="@color/red_500"
android:startColor="@color/green_500" />
</shape>
</item>
</layer-list>
Or using:
getPaint().setShader(new LinearGradient(0,0,0,textView.getLineHeight(), startColor, endColor, Shader.TileMode.REPEAT));
- setAlpha() line 130 is killing this object. Is there a way to bring the text to the front and have set the text and customprogress at their proper colors?
Loving this Progress Bar.