9

I have a custom Circular Progressbar. This is the drawable I have for it to be determinate:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@android:id/secondaryProgress">
    <shape
        android:innerRadiusRatio="6"
        android:shape="ring"
        android:thicknessRatio="20.0"
        android:useLevel="true">
     <gradient
          android:centerColor="#999999"
          android:endColor="#999999"
          android:startColor="#999999"
          android:type="sweep" />
    </shape>
  </item>
  <item android:id="@android:id/progress">
   <rotate
      android:fromDegrees="270"
      android:pivotX="50%"
      android:pivotY="50%"
      android:toDegrees="270">

  <shape
      android:innerRadiusRatio="6"
      android:shape="ring"
      android:thicknessRatio="20.0"
      android:useLevel="true">


    <rotate
        android:fromDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="0" />

    <gradient
        android:centerColor="?attr/colorAccent"
        android:endColor="?attr/colorAccent"
        android:startColor="?attr/colorAccent"
        android:type="sweep" />

      </shape>
    </rotate>
  </item>
</layer-list>

I want it to show the progress in a clockwise direction, but now it's showing counterclockwise.

How do I change it?

Mahozad
  • 18,032
  • 13
  • 118
  • 133
amitairos
  • 2,907
  • 11
  • 50
  • 84
  • how are you incrementing progress? I have a circular progress bar, used your drawable, and it rotates clockwise – khusrav Jul 05 '17 at 21:36

5 Answers5

20

I guess you're using an rtl language? You can force the progress bar to an ltr or clockwise direction by setting the layoutDirection property on your ProgressBar.

<ProgressBar
    ...
    android:layoutDirection="ltr" />
tachyonflux
  • 20,103
  • 7
  • 48
  • 67
2

By using latest versions of material design library, you can achieve this:

  • in the layout with this attribute
    app:indicatorDirectionCircular
    
  • or programmatically with this method
    setIndicatorDirection()
    

Refer here for more info.

Mahozad
  • 18,032
  • 13
  • 118
  • 133
0

Change this

<rotate
    android:fromDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="0" />

to

<rotate
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" />
Cecil Paul
  • 595
  • 6
  • 27
0

I'm not sure if it will work, but just try to set android:toDegrees="-360" like this :

<rotate
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="-360" />
ziLk
  • 3,120
  • 21
  • 45
0

you can change rotation on Y axis by 180 degrees

android:rotationY="180"
Mohamed Shawky
  • 159
  • 2
  • 4