次のように onDraw をオーバーライドしたテキスト付きの進行状況バーがあります。
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint textPaint = new Paint();
textPaint.setAntiAlias(true);
textPaint.setColor(textColor);
textPaint.setTextSize(textSize);
Rect bounds = new Rect();
textPaint.getTextBounds(text, 0, text.length(), bounds);
float fx = getX();
float fy = getY();
int x = getWidth() / 2 - bounds.centerX();
int y = getHeight() / 2 - bounds.centerY();
canvas.drawText(text, x, y, textPaint);
}
テキストをセカンダリ プログレス内に配置しようとしていますが、セカンダリ プログレスの現在の幅、基本的に現在のプログレスの幅を取得する方法がよくわかりません。