我只能使用以下代码将背景添加到屏幕中添加的字段:
VerticalFieldManager manager = new VerticalFieldManager();
Bitmap image = Bitmap.getBitmapResource("Penguins.jpg");
Background bg = BackgroundFactory.createBitmapBackground(image);
manager.setBackground(bg);
manager.add(new LabelField("HEll"));
add(manager);</code>
输出屏幕如下所示:
如何将图像填满整个屏幕,并在其上方显示字段。谢谢
答案 0 :(得分:1)
Bitmap background = Bitmap.getBitmapResource("background.png");
VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH) {
public void paint(Graphics g) {
g.drawBitmap(0, 0, "Device Width", "Device Height",
background, 0, 0);
super.paint(g);
}
};
vfm.add(new LabelField("HEll"));
add(vfm);
答案 1 :(得分:1)
您也可以使用此代码在Blackberry中设置背景图像,但这仅适用于5.0或更高版本。
Background bg = BackgroundFactory.createBitmapBackground(Bitmap bitmap);
// OR
Background bg = BackgroundFactory.createBitmapBackground(Bitmap bitmap, int positionX, int positionY, int repeat);
this.getMainManager().setBackground(bg);