2

I am setting a custom progressbarDrawable to my horizontal progressBar but it seems that its filling the full progressbar so its always set to 100%.

Here is my drawable:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@android:id/background"
        android:drawable="@drawable/gold_progress_bg" />
    <!--<item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/gold_progress_progress" />-->
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/gold_progress_progress" />

</layer-list>

here is the style i apply to the view:

<style name="DottedVehicleProgressBar" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:indeterminateOnly">false</item>
        <item name="android:progress">50</item>
        <item name="android:progressDrawable">@drawable/dotted_progress_drawable</item>
    </style>

and here is the defining of the view in xml:

<ProgressBar
        android:id="@+id/vehicle_dotted_progress"
        style="@style/DottedVehicleProgressBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:progress="50"
        app:tickInterval="10.0" />
Darko Petkovski
  • 3,892
  • 13
  • 53
  • 117
  • that looks like a progress drawable for a seekbar layout. a ProgressBar is supposed to show the overall progress of an executing task. If you want to create your own custom progress bar, check [this](http://stackoverflow.com/a/4454450/1055954) SO answer. Works with drawables as well. – Steve C. May 04 '16 at 09:36
  • Did you find a solution? – Kidus Apr 08 '17 at 11:19

1 Answers1

1

According to an answer from here, surrounding your <layer-list> by the <clip> element will fix it.

<?xml version="1.0" encoding="utf-8"?>
<clip>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

        <item
            android:id="@android:id/background"
            android:drawable="@drawable/gold_progress_bg" />
        <!--<item
            android:id="@android:id/secondaryProgress"
            android:drawable="@drawable/gold_progress_progress" />-->
        <item
            android:id="@android:id/progress"
            android:drawable="@drawable/gold_progress_progress" />

    </layer-list>
</clip>
Community
  • 1
  • 1
Kidus
  • 1,785
  • 2
  • 20
  • 36