Govula Srinivas
Govula Srinivas

Reputation: 173

Blackberry reducing the font size to fit in the listfield row

i am using the ListField for drawing the text ,Problem is if the size of the text is more then the screen width the remaining text is not appearing.Is there any way where i can reduce the font size for a particular rows whose text content is more to fit in to the ListField drawing region.

Upvotes: 2

Views: 691

Answers (1)

Richard
Richard

Reputation: 8920

In your ListFieldCallback code you will have a drawListRow() method. Select the font there:

public void drawListRow(ListField list, Graphics g, int index, int y, int w) 
{
    // Set text to draw in textString:

    String textString = ...
    Font smallerFont = FontFamily.forName(FontFamily.FAMILY_SYSTEM).getFont(fontStyle,
        fontSize);
    g.setFont(smallerFont);
    g.drawText(textString, 0, y, DrawStyle.TOP|DrawStyle.LEFT, w);
}

Upvotes: 3

Related Questions