j'étudie l'application comme ceci, .où sont les références des numéros?
/**
* draw the hour text (12、3、6、9)
* draw the arc
*/
private void drawTimeText() {
//draw the hour text
String timeText = "12";
mTextPaint.getTextBounds(timeText, 0, timeText.length(), mTextRect);
int textLargeWidth = mTextRect.width();//两位数字的宽
mCanvas.drawText("12", getWidth()/2 - textLargeWidth/2, mPaddingTop + mTextRect.height(), mTextPaint);
timeText = "3";
mTextPaint.getTextBounds(timeText, 0, timeText.length(), mTextRect);
int textSmallWidth = mTextRect.width();//一位数字的宽
mCanvas.drawText("3", getWidth() - mPaddingRight - mTextRect.height()/2 - textSmallWidth/2,
getHeight()/2 + mTextRect.height()/2, mTextPaint);
mCanvas.drawText("6", getWidth()/2 - textSmallWidth/2, getHeight() - mPaddingBottom, mTextPaint);
mCanvas.drawText("9", mPaddingLeft + mTextRect.height()/2 - textSmallWidth/2,
getHeight()/2 + mTextRect.height()/2, mTextPaint);
//draw the arc
mCircleRectF.set(mPaddingLeft + mTextRect.height()/2 + mCircleStrokeWidth/2,
mPaddingTop + mTextRect.height()/2 + mCircleStrokeWidth/2,
getWidth() - mPaddingRight - mTextRect.height()/2 + mCircleStrokeWidth/2,
getHeight() - mPaddingBottom - mTextRect.height()/2 + mCircleStrokeWidth/2);
for (int i = 0; i < 4; i++) {
mCanvas.drawArc(mCircleRectF, 5 + 90 * i, 80, false, mCirclePaint);
}
je ne sais pas quand dessiner le texte d'une heure "3",
mCanvas.drawText("3", getWidth() - mPaddingRight - mTextRect.height()/2 - textSmallWidth/2,
getHeight()/2 + mTextRect.height()/2, mTextPaint);
utilisation canvas.drawText(),
void drawText (String text,
int start,
int end,
float x,
float y,
Paint paint)
"y" signifie la ligne de base du nombre , je ne connais pas les règles de base du nombre, comme "3", où est la référence du nombre? je recherche google le "baseline", mais il s'agit de l'alphabet anglais de base, rien sur le nombre de base.
merci beaucoup !! –