我需要创建一个行为drawable,其行为与标准行为完全相同,但也会有背景和不同的厚度。
在下面的屏幕截图中,您可以看到它在背景中有不同的厚度和额外的响铃。
如果我能以编程方式更改背景环的厚度和颜色,那将是最好的。
我该怎么做?
答案 0 :(得分:0)
Looks like the best way to customize standard Android's progress widget is to write a custom progress drawable.
To implement indeterminate progress one can create a custom Drawable
that implements Animatable
interface. ProgressBar
widget will automatically start the animation once isIndeterminate
property is set to true
.
The idea is taken from the library: https://github.com/castorflex/SmoothProgressBar
When isIndeterminate
property equals to false
, ProgressBar uses different drawable. When the progress value is set, it calls drawable's "setLevel()" method. Following the same idea of custom drawable, one can implement onLevelChanged()
method, and update drawable state in it to reflect current progress.