5

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

DoubleP90
  • 1,249
  • 1
  • 16
  • 29

4 Answers4

2

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

Ewoks
  • 12,285
  • 8
  • 58
  • 67
1

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?

Community
  • 1
  • 1
pawegio
  • 1,722
  • 3
  • 17
  • 29
  • I don't think it's what i'm looking for, from what i understand this is an animation of a progress bar without a value, i need to give it a value (battery percentage) and based on the value it has to change – DoubleP90 Aug 15 '12 at 17:38
0

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);
}
Mani
  • 3,394
  • 3
  • 30
  • 36
0

You can use below library

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

This is exactly which support complex gradient with circular progress bar

himb2001
  • 1,371
  • 1
  • 10
  • 7