S.P.
S.P.

Reputation: 2564

How can I do that circular countdown go with the clockwise?

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);

Upvotes: 0

Views: 627

Answers (1)

Aditya Vyas-Lakhan
Aditya Vyas-Lakhan

Reputation: 13555

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" />

Upvotes: 2

Related Questions