Calculate String Width / Height on Blackberry
If I display 开发者_开发问答a string in a custom field using drawtext(txt,ax,ay) method, how can I calculate the string width / height.
Width:
int stringWidth = getFont().getAdvance(yourString);`
Height:
int stringHeight = getFont().getHeight();`
Those are if you're making the calls from within one of your Field
's methods (meaning you have extend
ed a Field
). However, if you're simply trying to draw the string and are wondering what ax
and ay
represent, those are positions, not dimensions.
精彩评论