开发者

Calculate String Width / Height on Blackberry

开发者 https://www.devze.com 2023-03-23 08:40 出处:网络
If I display 开发者_开发问答a string in a custom field using drawtext(txt,ax,ay) method, how can I calculate the string width / height.Width:

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 extended 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消