1

CircularProgressDrawable

This is the library i'm using in my project. MY APPROACH IS :

<com.rey.material.widget.ProgressView
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:id="@+id/progressviewmain"
        app:pv_progressStyle="@style/Material.Widget.ProgressView.Circular"
        app:pv_circular="true"
        android:background="#ffffff"
        app:pv_progressMode="indeterminate"
        app:pv_autostart="true"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"/>

and Code is :

progressView = (ProgressView)findViewById(R.id.progressviewmain);

functions are :

private void startprogress(ListView listView, ProgressView progressView){
    progressView.setVisibility(View.VISIBLE);
}
    private void stopprogress(ListView listView, ProgressView progressView){
        listView.setVisibility(View.VISIBLE);
        progressView.setVisibility(View.GONE);
    }

all of this is working fine but as there in documentation we can see CircularProgressDrawable with 2 different forms i'm not able to get 1st one in which colors are changing . How to give input the array of colors to that ?? how to use attr?

1 Answer 1

4

As it said in doc you can give the view array of colors with cpd_strokeColors

cpd_strokeColors - The array of colors will be used as stroke's color (for indeterminate mode).

Update 1: To change the attributes you have to create a style in res/values/styles.xml like this:

<style name="CircularProgress">
        <item name="cpd_padding">0dp</item>
        <item name="cpd_initialAngle">0</item>
        <item name="cpd_maxSweepAngle">270</item>
        <item name="cpd_minSweepAngle">1</item>
        <item name="cpd_strokeSize">4dp</item>
        <item name="cpd_strokeColor">@color/colorAccent</item>
        <item name="cpd_strokeSecondaryColor">@android:color/transparent</item>
        <item name="cpd_reverse">false</item>
        <item name="cpd_strokeColors">@array/rainbow</item>
        <item name="cpd_rotateDuration">1000</item>
        <item name="cpd_transformDuration">600</item>
        <item name="cpd_keepDuration">200</item>
        <item name="cpd_transformInterpolator">@android:anim/decelerate_interpolator</item>
        <item name="pv_progressMode">buffer</item>
        <item name="cpd_inAnimDuration">0</item>
        <item name="cpd_outAnimDuration">@android:integer/config_mediumAnimTime</item>
</style>

Then assign it to your view:

<com.rey.material.widget.ProgressView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/progressviewmain"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:pv_autostart="true"
        app:pv_circular="true"
        app:pv_progressMode="indeterminate"
        app:pv_progressStyle="@style/CircularProgress"/>

And it will work.

Sign up to request clarification or add additional context in comments.

6 Comments

actually i'm quite newbie so please can you tell me the method to implementation
Actually how to call cpd_strokeColors ........... from xml or java ? I'm trying to use it in xml i'm not able to do this and also not any method in java named this
I think it would be like this: app:cpd_strokeColors="@color/rainbow" while rainbow is the name of array of colors in res/values/colors.xml and it's like: <array name="rainbow"> <item>@color/bright_pink</item> <item>@color/red</item> <item>@color/orange</item> <item>@color/yellow</item> </array>
<com.rey.material.widget.ProgressView android:layout_width="48dp" android:layout_height="48dp" android:id="@+id/progressviewmain" app:pv_progressStyle="@style/Material.Drawable.CircularProgress" app:pv_circular="true" app:cpd_strokeColors="@array/rainbow" app:cpd_inStepColors="@array/rainbow" app:pv_progressMode="indeterminate" app:pv_autostart="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/> i'm using this but still same bar :(
@HumzaMalik I just edit my answer. Look at it and it will fix your problem. Mark it as answer if it helped you.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.