1

Centering text(String) in a surface view

view story
linux-howto

http://stackoverflow.com – How do you horizontally center a String in a surface view? I don't want c.drawText(""+score, c.getWidth()/2, y); Because this will display text starting at the center of the screen. I want something like c.drawText(""+score, c.getWidth()/2-score.length()/2*fontSize, y); Is there an equation to solve this problem? If not, are there any other ways to center text in a surface view? BTW I'm using a custom font, I don't know if that changes anything or not. If you need to know any extra information about the font please comment. (HowTos)