static-progress-bar icon indicating copy to clipboard operation
static-progress-bar copied to clipboard

Color Gradient

Open martinsing opened this issue 8 years ago • 0 comments

I love this class. I think it's so awesome and is my favorite progress bar so far. Few things:

  • [ ] getColor() is deprecated. Replace getResources().getColor( with ContextCompat.getColor(getContext(), in lines 75&76.
  1. 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));

  1. 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.

martinsing avatar Feb 22 '17 08:02 martinsing