2

I want to rotate circular progress bar anti clock wise.

<?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="3dp"
    android:useLevel="true">

    <gradient
        android:angle="0"
        android:endColor="@color/rotateBar"
        android:startColor="@color/rotateBar"
        android:type="sweep"
        android:useLevel="false" />
</shape>
</rotate>

From this way I am able to move clockwise but I want to rotate my progress bar in opposite direction.Any Solution?

Like this

Khurram Ansar
  • 97
  • 1
  • 10
  • 1
    Does this answer your question? [How can I do that circular countdown go with the clockwise?](https://stackoverflow.com/questions/39721040/how-can-i-do-that-circular-countdown-go-with-the-clockwise) – Mahozad Jan 08 '21 at 10:10

1 Answers1

0

Create a customized class that extends ProgressBar and create your progress bar in xml file using that class.

public class CustomCircularProgress extends ProgressBar {

public CustomCircularProgress(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
}

public CustomCircularProgress(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
}

public CustomCircularProgress(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}

@Override
protected synchronized void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub

    canvas.scale(-0.5f, 0.5f, super.getWidth() * 0.5f, super.getHeight() * 0.5f);
    super.onDraw(canvas);
}}

Just check out scale (float sx, float sy, float px, float py) in https://developer.android.com/reference/android/graphics/Canvas.html#scale(float,float,float,float)

I got it from stackoverflow itself. But I didn't get that link for refering