开发者

how to set an image as background in blackberry

I was able to add the background only to the fields that were added in the screen with the below code: VerticalFieldManager manager = new VerticalFieldManager();

Bi开发者_如何学运维tmap image = Bitmap.getBitmapResource("Penguins.jpg");

    Background bg = BackgroundFactory.createBitmapBackground(image);
    manager.setBackground(bg);
    manager.add(new LabelField("HEll"));
    add(manager);</code>

the output screen is like below:

how to set an image as background in blackberry

How will get the image filled with whole screen, with the fields visible on top of it. Thank you


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);


You can also use this code to set the background image in Blackberry, But this works only 5.0 or above.

Background bg = BackgroundFactory.createBitmapBackground(Bitmap bitmap);

// OR

Background bg = BackgroundFactory.createBitmapBackground(Bitmap bitmap, int positionX, int positionY, int repeat);

this.getMainManager().setBackground(bg);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜