Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProgressBar Circle shows no progress on android L (API 21)

I have a circular ProgressBar to count down time. It workes perfectly on kitkat and before, but on android L it always shows a full circle no matter what progress I set.

Image

layout.xml

<ProgressBar
                android:id="@+id/progressBar1"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:indeterminate="false"
                android:max="200"
                android:progress="100"
                android:progressDrawable="@drawable/progresscircle" />

progresscircle.xml

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

    <item>
        <shape
            android:innerRadiusRatio="3.4"
            android:shape="ring"
            android:thicknessRatio="6.0" >
            <solid 
                android:color="#ffffff" />
        </shape>
    </item>
        <item>
            <rotate
                android:drawable="@drawable/progress_particle"
                android:fromDegrees="0"
                android:pivotX="50%"
                android:pivotY="50%"
                android:toDegrees="360" />
        </item>

    </layer-list>
like image 999
Jonathan S Avatar asked Oct 23 '14 16:10

Jonathan S


1 Answers

The default value for android:useLevel under the tag incorrectly changed to false in the L Preview build. You can work around this by explicitly setting it to true.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape
            ...
            android:useLevel="true">
            <solid
                ...
like image 132
alanv Avatar answered Oct 21 '22 07:10

alanv