gpt4 book ai didi

java - 对齐黑莓的布局设计问题

转载 作者:行者123 更新时间:2023-12-04 05:37:10 26 4
gpt4 key购买 nike

我正在开发一个应用程序,我需要在 HorizontalFieldManage 中设置两个按钮.哪里Bitmap应该留在左边和另一个 LabelField应保持水平居中。在这里我尝试了很多次但无法先设置 Bitmap在左边所以你能帮我解决这个问题吗..

这是我的代码::

VerticalFieldManager VFM = new VerticalFieldManager(USE_ALL_WIDTH){
public void paint(Graphics g) {
g.setBackgroundColor(Color.WHITE);
g.clear();
super.paint(g);
}
};
HorizontalFieldManager HFM = new HorizontalFieldManager(FIELD_HCENTER){
public void paint(Graphics g) {
g.setBackgroundColor(Color.WHITE);
g.clear();
super.paint(g);
}
};

Bitmap logom1;
logom1 = Bitmap.getBitmapResource("logo48X48.png");
BitmapField imgField = new BitmapField(logom1,Field.FIELD_LEFT);
LabelField RegistrationLbl = new LabelField("Registration",FIELD_HCENTER | FIELD_BOTTOM);

FontFamily fontFamily[] = FontFamily.getFontFamilies();
Font font = fontFamily[1].getFont(FontFamily.CBTF_FONT, 20);
font = fontFamily[1].getFont(Font.BOLD, 25);
RegistrationLbl.setFont(font);

HFM.add(imgField);
HFM.add(RegistrationLbl);

VFM.add(HFM);
add(VFM);

最佳答案

试试这个(这不是正确的方法)-

        HorizontalFieldManager VFM = new HorizontalFieldManager(){
public void paint(Graphics g) {
g.setBackgroundColor(Color.WHITE);
g.clear();
super.paint(g);
}
};

HorizontalFieldManager LogoHFM = new HorizontalFieldManager(FIELD_LEFT);
Bitmap logom1;
logom1 = Bitmap.getBitmapResource("logo48X48.png");
BitmapField imgField = new BitmapField(logom1);
LogoHFM.add(imgField);


LabelField RegistrationLbl = new LabelField("Registration",FIELD_HCENTER);
FontFamily fontFamily[] = FontFamily.getFontFamilies();
Font font = fontFamily[1].getFont(FontFamily.CBTF_FONT, 20);
font = fontFamily[1].getFont(Font.BOLD, 25);
RegistrationLbl.setFont(font);
RegistrationLbl.setMargin(0,0,0,(Display.getWidth()-logom1.getWidth())/4);


VFM.add(LogoHFM);
VFM.add(RegistrationLbl);
add(VFM);

关于java - 对齐黑莓的布局设计问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11789856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com