is there an easy way to center a text vertically and horizontally on a bitmap?
I tried to calculate the xPosition and the yPosition of the text, but i can't figure out who the center the text vertically.
This is how i centered the text horizontally:
Using java Syntax Highlighting
- // Here we calculate the xPos of the text with the help of getTextWidths()
- // which gives us the width in px of a certain text
- int textXPos = (size-paintText.getTextWidths(value, new float[1]) ) / 2;
- int textYPos = ????? ;
- // draw Text
- canvas.drawText(value, textXPos, textYPos, paintText);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
size is the height and also the width of the canvas...
I think it could help a lot to get the height of the text in px but I don't get it...
greetz



