【发布时间】:2018-04-06 18:51:36
【问题描述】:
【问题讨论】:
-
也许this post 有帮助?
标签: android progress-bar draw shape
【问题讨论】:
标签: android progress-bar draw shape
您可以通过使用 Progressbar 扩展来创建自定义形状
试试这个代码,根据你的需要定制
public class CustomBar extends ProgressBar {
Paint p = new Paint();
int progress;
public CustomBar(Context context) {
super(context);
p.setColor(Color.GREEN);
}
@Override
protected synchronized void onDraw(Canvas canvas) {
canvas.drawLine(0, 0, getWidth(), 0, p);
canvas.drawLine(0, 0, 0, getHeight(), p);
canvas.drawArc(new Rect(0, 0, getWidth(), getHeight()), 40, true, p);
/**
* Whatever drawing is needed for your Layout
* But make sure you use relative lenghts and heights
* So you can reuse your Widget.
* Also use the Progress Variable to draw the filled part
* corresponding to getMax()
*/
}
}
更多详情请查看以下链接
【讨论】: