android ProgressBar without clipping?
android, progress-bar
Solution
Create `layer-list` drawable like this.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:startColor="#234"
android:centerColor="#234"
android:centerY="0.75"
android:endColor="#a24"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="#144281"
android:centerColor="#0b1f3c"
android:centerY="0.75"
android:endColor="#06101d"
android:angle="270"
/>
</shape>
</clip>
</item>
The main point is to make item with `android:id="@android:id/background` use `@android:color/transparent`
And then set it to `android:progressDrawable` property of `ProgressBar`
<ProgressBar
android:id="@+id/progressBar"
android:progressDrawable="@drawable/your_layer_list_created_on_previous_step"
android:layout_width="fill_parent"
android:layout_height="8dp"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminateOnly="false"
android:max="100" />
Problem
Any default ProgressBar has a ClipDrawable level, for example a green Drawable is filling the grey background one on my device, the yellow on some others. My question: is that possible to create a ProgressBar without this (partly) empty background when progress is less than max or should I use an ImageView instead? I need only the ClipDrawable to change its width so it looks like a diagram while the grey background never appears.