答案 0 :(得分:0)
您可以通过使用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()
*/
}
}
有关详细信息,请查看以下链接