我正在尝试为Blackberry 9900模拟器设置背景图像,我编写了如下代码
BitmapField _bitmap ;
private int phoneWidth = Display.getWidth();
private int cellHeight = Display.getHeight();
public MyScreen(){
super(Manager.USE_ALL_WIDTH | Manager.NO_VERTICAL_SCROLL);
final Bitmap background = Bitmap.getBitmapResource("black.jpg");
VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH) {
public void paint(Graphics g) {
Bitmap scaled = new Bitmap(phoneWidth, cellHeight);
background.scaleInto(scaled, Bitmap.SCALE_TO_FIT);
g.drawBitmap(0, 0, phoneWidth, cellHeight,
background, 0, 0);
super.paint(g);
}
};
add(vfm);
}
并且我在模拟器中获得输出
我希望背景图片填写完整的背景,任何帮助将不胜感激,提前感谢您。
答案 0 :(得分:3)
问题在这里
g.drawBitmap(0, 0, phoneWidth, cellHeight,
background, 0, 0);
你必须绘制缩放位图
g.drawBitmap(0, 0, phoneWidth, cellHeight,
scaled , 0, 0);