DoubleP90
DoubleP90

Reputation: 1249

Circular progress bar

I am working on an application that needs a "circular progress bar" something like this (it doesn't need to have color changes or be empty in the middle, a simple thing would be enought for me, but if you'd like to tell me how to make color changes aswell i'll be happy to learn :) )

enter image description here

I want to use it to show the battery percentage in my app

Upvotes: 5

Views: 10629

Answers (4)

himb2001
himb2001

Reputation: 1361

You can use below library

https://github.com/chillerlabs/android-circular-progress-bar

This is exactly which support complex gradient with circular progress bar

Upvotes: 0

Mani
Mani

Reputation: 3467

use this method to and set it to image view it draw a bitmap on image view. u can use this piece of code to show a progress dialog.

private void circularImageBar(ImageView iv2, int i) {


    Bitmap b = Bitmap.createBitmap(300, 300,Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b); 
    Paint paint = new Paint();

        paint.setColor(Color.parseColor("#c4c4c4"));
        paint.setStrokeWidth(10);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawCircle(150, 150, 140, paint);

        paint.setColor(Color.parseColor("#FFDB4C"));
        paint.setStrokeWidth(10);   
        paint.setStyle(Paint.Style.FILL);
        final RectF oval = new RectF();
        paint.setStyle(Paint.Style.STROKE);
        oval.set(10,10,290,290);

        canvas.drawArc(oval, 270, ((i*360)/100), false, paint);
        paint.setStrokeWidth(0);    
        paint.setTextAlign(Align.CENTER);
        paint.setColor(Color.parseColor("#8E8E93")); 
        paint.setTextSize(140);

        canvas.drawText(""+i, 150, 150+(paint.getTextSize()/3), paint); 

        iv2.setImageBitmap(b);
}

Upvotes: 0

Ewoks
Ewoks

Reputation: 12435

I hope something like this lib would help

Definition in layout is simple:

<com.lylc.widget.circularprogressbar.example.CircularProgressBar
    android:id="@+id/circularprogressbar1"
    style="@style/Widget.ProgressBar.Holo.CircularProgressBar"
    android:layout_width="120dip"
    android:layout_height="120dip"
    android:layout_marginTop="10dip"
    circular:subtitle="subtitle"
    circular:title="Title" />

and usage is not complicated as well:

CircularProgressBar c3 = (CircularProgressBar) findViewById(R.id.circularprogressbar3);
c3.setTitle("June");
c3.setSubTitle("2013");
c3.setProgress(42);

It supports animated progress as well in case you need it. All credits to original author. I just found it. Hope it helped

Upvotes: 2

pawegio
pawegio

Reputation: 1732

I do not know if I understood you well, but I think that it can help you: How to change color in circular progress bar?

Upvotes: 1

Related Questions