Вы можете перейти по этой ссылке https://developer.android.com/training/custom-views/custom-drawing#java. Содержит подробное описание позиционирования.В вашем случае,
, вам сначала нужно создать текст
textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(textColor);
if (textHeight == 0) {
textHeight = textPaint.getTextSize();
} else {
textPaint.setTextSize(textHeight);
}
piePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
piePaint.setStyle(Paint.Style.FILL);
piePaint.setTextSize(textHeight);
shadowPaint = new Paint(0);
shadowPaint.setColor(0xff101010);
shadowPaint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL));
примерно так, и вам нужно установить отступы и разместить его там, где вы хотите, как показано ниже
// Account for padding
float xpad = (float)(getPaddingLeft() + getPaddingRight());
float ypad = (float)(getPaddingTop() + getPaddingBottom());
// Account for the label
if (showText) xpad += textWidth;
float ww = (float)w - xpad;
float hh = (float)h - ypad;
// Figure out how big we can make the pie.
float diameter = Math.min(ww, hh);
Я получил весь этот код с вышеупомянутого URL.
Вам необходимо добавить приведенный ниже код для позиционирования по центру
Paint yourPaint = new Paint();
int xP = (canvas.getWidth() / 2);
int yP = (int) ((canvas.getHeight() / 2) - ((yourPaint .descent()yourPaint .ascent()) / 2)) ;
canvas.drawText(yourTextView, xP, yP, yourPaint);