내 앱에서 맞춤 LabelField를 구현 중입니다. 그것은 제대로 표시되지 않습니다 글꼴 크기를 늘리면 작은 글꼴로 잘 작동합니다. 여기에서이 이미지에서 볼 수 있습니다.Blackberry의 Custom LabelField에서 텍스트가 올바르게 표시되지 않습니다.
당신은 텍스트의 절반을 보여주는 이미지를 볼 수 있습니다. 어떻게 이것을 극복 할 수 있습니까?
여기 사용자 정의 LabelField에 대한 코드를 제공하고 있습니다. 내가 뭘 잘못하고 있는지 말해줘. 당신의 layout
방법에서
public class CustomLabelField extends Field
{
private String label;
private int fontSize;
private int foregroundColor;
private int backgroundColor;
public CustomLabelField(String label, int fontSize, int foregroundColor,
int backgroundColor,long style)
{
super(style);
this.label = label;
this.foregroundColor = foregroundColor;
this.backgroundColor = backgroundColor;
this.fontSize = fontSize;
}
protected void layout(int width, int height) {
setExtent(width, getFont().getHeight());
}
protected void paint(Graphics graphics) {
graphics.setBackgroundColor(backgroundColor);
graphics.clear();
graphics.setFont(setMyFont());
graphics.setColor(foregroundColor);
graphics.drawText(label, 0, 0, (int)(getStyle()& DrawStyle.ELLIPSIS | DrawStyle.HALIGN_MASK),getWidth() - 6);
}
// Get font for the label field
public Font setMyFont()
{
try {
FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Serif");
Font appFont = alphaSansFamily.getFont(Font.PLAIN, fontSize, Ui.UNITS_pt);
return appFont;
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}