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


和IAM这样在模拟器中获取输出



我希望背景图片充满整个背景,我们将不胜感激,在此先感谢您。

最佳答案

问题在这里

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


您必须绘制比例位图

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

关于java - 如何在Blackberry 7.1中设置背景图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16438384/

10-08 21:28