0

I have a circular progressbar that is a countdown. The countdown starts at the top of the circular progressbar that's is fine, but go to the left doing the countdown. That I want is the rotation of the countdown go to the right, like the clockwise.

My circle_progress_foreground.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@android:id/progress">
        <shape
            android:innerRadiusRatio="3"
            android:shape="ring"
            android:thicknessRatio="30"
            android:useLevel="true">

            <gradient
                android:startColor="@color/circle_progress_two"
                android:endColor="@color/circle_progress"
                android:type="sweep" />
        </shape>
    </item>
</layer-list>

The progressbar in my layout

<ProgressBar
            android:id="@+id/progressbar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="280dip"
            android:layout_height="290dip"
            android:indeterminate="false"
            android:progressDrawable="@drawable/circle_progress_foreground"
            android:background="@drawable/circle_shape"
            android:max="100"
            android:rotation="-90"
            android:layout_alignParentTop="true"
            android:layout_alignLeft="@+id/progressBar"
            android:layout_alignStart="@+id/progressBar"
            android:layout_centerHorizontal="false"
            android:layout_centerInParent="false"
            android:layout_centerVertical="false" />

The code in my class:

mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
S.P.
  • 2,274
  • 4
  • 26
  • 57
  • Does this answer your question? [Mirror (flip) a View / ProgressBar](https://stackoverflow.com/questions/14022298/mirror-flip-a-view-progressbar) – Mahozad Jan 08 '21 at 10:11

1 Answers1

2

Try this way to to set your rotation

circle_progress_foreground.xml

 <?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="270"
    android:toDegrees="270">
    <shape
        android:innerRadiusRatio="2.5"
        android:shape="ring"
        android:thickness="1dp"
        android:useLevel="true">

        <gradient
            android:angle="0"
            android:endColor="#007DD6"
            android:startColor="#007DD6"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

circle_shape

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadiusRatio="2.5"
    android:thickness="1dp"
    android:useLevel="false">

    <solid android:color="#CCC" />

</shape>

ProgressBar

<ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:indeterminate="false"
        android:progressDrawable="@drawable/circle_progress_foreground"
        android:background="@drawable/circle_shape"
        style="?android:attr/progressBarStyleHorizontal"
        android:max="100"
        android:progress="65" />
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
  • Is still doing the rotation in the opposite way that the clockwise. I want that rotate in the same way that the clockwise – S.P. Sep 27 '16 at 09:40
  • i dint get you what ? – Aditya Vyas-Lakhan Sep 27 '16 at 09:46
  • Hi. If working your code, but when start doing the countdown is not doing the clockwise. Is rotating to left from right, and I want that rotate to right to left in the same way that the clockwise. Now I get the opposite rotation. – S.P. Sep 27 '16 at 09:57
  • Yes, I've tried with edit answer and fo the opposite to the clockwise – S.P. Sep 27 '16 at 12:15
  • 1
    Ive got it with this I go to accept your answer. If you can edit and add this correct values that work for me, will be perfect. – S.P. Sep 27 '16 at 13:26