开发者

How to Change Font Size of Text in ListField?

In drawListRow() method, I draw texts using graphics.drawText()开发者_开发百科. How can I change the font size of text?


In your ListFieldCallback code, override drawListRow() and set the Font there:

public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
    Font myFont= FontFamily.forName(FontFamily.FAMILY_SYSTEM).getFont(fontStyle,
        fontSize);
    g.setFont(myFont);
    g.drawText(str, 0, y, DrawStyle.TOP|DrawStyle.LEFT, w);
}


Have you tried first setting the Graphics#setFont with your newly sized font?

Perhaps using Font#derive(style, size):

http://www.blackberry.com/developers/docs/4.3.0api/net/rim/device/api/ui/Font.html#derive(int,%20int)

Just quickly perused the javadocs, not actually done this. something like:

font myFont8 = ...;

Font myFont16 = myFont8.derive((myFont8.getStyle(), 16);

g.setFont(myFont16);

g.drawText(...);

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜