Is开发者_如何学Python there any way to make the progress bar into a circle shape? I have a play button in my apps and would like to show the progress of loading the song around the button.
The ProgressBar widget has two modes which affect how it looks:
- In progress mode, you get the straight line where you can set the progress value as you go along
- In indeterminate mode, you get a circular animation that spins until you stop it
I recently built a countdown progress indicator where I wanted a box to "unwind" like a clock going backwards as time ticked down. This sounds very much like what you want to do, only in reverse.
What I did was create my own class that subclasses View. Then in my onDraw() override I painted directly on the canvas. It might sound like too much trouble, but it's really easy and actually kinda controlling the whole painting process.
Something like this to draw the box all the way around...
@Override
public void onDraw(Canvas canvas) {
Rect rect = canvas.getClipBounds();
rect.inset(10f, 10f);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Join.ROUND);
paint.setColor(Color.BLUE);
paint.setStrokeWidth(10f);
canvas.drawRect(countdownRect, paint);
}
...there are plenty of draw methods you can use to draw other shapes, lines, paths, circles, etc.
精彩评论