安卓:创建形进度自定义的最佳方法自定义、进度、方法

2023-09-07 23:14:08 作者:对饮东篱

我想创建一个自定义形状的进度,这将根据其进展情况改变颜色(但这几乎是一个不同的问题。)。

I would like to create a custom shaped progressbar, which would change color according to its progress (but this is almost a different question..).

那么,这将是创建一个自定义形状的进度像一个下面的图片(对不起,坏的将MS Paint绘画技巧)的最佳方法:

So what would be the best way to create a custom shaped progressbar like the one on the image below (sorry for bad MS Paint drawing skills):

推荐答案

要拥有你应该创建进度派生的自定义类,并完全覆盖的OnDraw()方法所有的可能性。绘制拱门就在旁边,你可以使用 canvas.drawArc()并更改栏的颜色,你可以简单地调整油漆颜色。

To have all possibilities you should create a custom class derived from progressbar and completely override the onDraw() Method. to draw the Arch on the side you can use canvas.drawArc() and to change the color of the bar you can simply adjust the Paint Color.