0

I would like to use ProgressBar with the completed part with color black, alpha 0.5 (so it can see through), while the remaining part is white alpha 1.0 (which is not transparent at all).

I try to use

<item android:id="@android:id/background">
    <shape>
        <solid android:color="@color/white" />
    </shape>
</item>
<item android:id="@android:id/progress">
    <clip>
        <shape>
            <solid android:color="@color/black" />
        </shape>
    </clip>
</item>

and set the clipDrawable's alpha to be 0.5. But it turns out the completed (left) part of the progress bar is not transparent since the background is not transparent.

Is there a way to achieve my goal?

enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
mlin956
  • 345
  • 1
  • 5
  • 13

1 Answers1

0

this is what you can use to customize your progress bar

<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
    <shape>
        <gradient
            android:angle="270"
            android:centerColor="#00613e"
            android:centerY="1.0"
            android:endColor="#00613e"
            android:startColor="#00613e" />
    </shape>
</item>

<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
    <clip>
        <shape>
            <gradient
                android:angle="270"
                android:centerColor="#f6e41a"
                android:centerY="1.0"
                android:endColor="#f6e41a"
                android:startColor="#f6e41a" />
        </shape>
    </clip>
</item>

007
  • 516
  • 1
  • 5
  • 17