1

我正在尝试为 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);
 }

我正在像这样在模拟器中获得输出

在此处输入图像描述

我希望背景图像填充完整的背景,任何帮助将不胜感激,提前谢谢你。

4

1 回答 1

3

问题在这里

 g.drawBitmap(0, 0, phoneWidth, cellHeight,
                             background, 0, 0);

你必须绘制缩放位图

 g.drawBitmap(0, 0, phoneWidth, cellHeight,
                             scaled , 0, 0);
于 2013-05-08T10:38:08.337 回答