我有一个背景图像,并在一个屏幕上覆盖了 2 个 LabelField、一个 BasicEditField 和一个 ButtonField。我的问题是我的背景图像在按钮底部后被切断,而不是完全填满屏幕。(为了便于阅读,我删除了多余的代码)
VerticalFieldManager bgManager = new VerticalFieldManager(Manager.USE_ALL_WIDTH |
Manager.NO_VERTICAL_SCROLL |
Manager.NO_VERTICAL_SCROLLBAR) {
//Override the paint method to draw the background image.
public void paint(Graphics graphics)
{
//Draw the background image and then call super.paint
//to paint the rest of the screen.
graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
this.add(bgManager);
LabelField header = new LabelField("", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
header.setText("Search by Drug Name");
bgManager.add(header);
LabelField subtitle = new LabelField("", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
subtitle.setText("(brand name or generic)");
bgManager.add(subtitle);
HorizontalFieldManager hfm = new HorizontalFieldManager();
final BasicEditField edit = new BasicEditField("", "", 50, EditField.EDITABLE | BasicEditField.NO_NEWLINE) {
//code to make background of text box white
}
};
hfm.add(edit);
ButtonField search = new ButtonField("Search");
search.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
//do something
}
});
如果我添加Manager.USE_ALL_HEIGHT
到,我的背景图像会完全填满屏幕bgManager
,但随后我的整个屏幕变得可无限滚动。没有Manager.USE_ALL_HEIGHT
,我的屏幕根本无法滚动(正确),但背景图像在内容末尾被切断。
如何构建此屏幕,使其不可滚动并具有占据整个可见屏幕的背景图像?
这看起来是错误的:
这是正确的(但滚动不正确):
这是我正在使用的背景图片: