开发者

how to set an image as background in blackberry

开发者 https://www.devze.com 2023-04-12 06:21 出处:网络
I was able to add the background only to the fields that were added in the screen with the below code:

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

精彩评论

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

关注公众号