Reduce size of EditField
I am creating five EditFields with corresponding label fields. The Ed开发者_运维技巧itFields use the full width of the screen but I need only want them to use a particular width.
try this code:-
BasicEditField bef = new BasicEditField("BBDeveloper","")
{
public int getPreferredHeight()
{
return 30;
}
public int getPreferredWidth()
{
return 100;
}
public void layout(int width, int height)
{
setExtent(getPreferredWidth(), getPreferredHeight());
super.layout(getPreferredWidth(), getPreferredHeight());
}
};
alter the getPreferredWidth() and getpreferredHeight() returning values... and see if this help you out....
set the change font bellow the rewritable methods like these:
lbDesc = new LabelField(title, LabelField.USE_ALL_WIDTH)
{
protected void paint(Graphics g)
{
//Font font = Font.getDefault().derive(Font.PLAIN,6,Ui.UNITS_pt);
//g.setFont(font);
g.setColor(Color.BLACK);
invalidate();
super.paint(g);
}
};
Font font = Font.getDefault().derive(Font.PLAIN,6,Ui.UNITS_pt);
lbDesc.setFont(font);
精彩评论