我一直致力于在我的应用程序中获取背景图像,并在屏幕底部为图像排列四个按钮。 下面我展示了我用来实现它的代码。 HorizontalFieldManager manager = new HorizontalFieldManager();
manager.add(new ButtonField("1", FIELD_BOTTOM));
manager.add(new ButtonField("2", FIELD_BOTTOM));
manager.add(new ButtonField("3", FIELD_BOTTOM));
manager.add(new ButtonField("4", FIELD_BOTTOM));
mWidth = Display.getWidth();
mHeight = Display.getHeight();
final Bitmap backgroundBitmap = Bitmap.getBitmapResource("intro.png");
HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH |HorizontalFieldManager.USE_ALL_HEIGHT)
{
//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, mWidth, mHeight,backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
BackGroundImage.add(manager);
add(BackGroundImage);
问题是,如果我把Field_BOTTOM放在horizontalFieldManager上,我现在无法将按钮放在屏幕的底部。
我很感谢这方面的帮助.. 谢谢,
答案 0 :(得分:1)
你可以这样做,在你的HorizontalFieldManager中将其参数设置为FIELD_BOTTOM
HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.FIELD_BOTTOM)
然后将您的按钮直接添加到此HorizontalFieldManager,然后使用setStatus(Field status)
MainScreen方法,即
this.setStatus(BackGroundImage);
希望这能解决你的问题。