开发者

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);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜