在我的黑莓应用程序中使用图片作为背景

时间:2012-02-08 16:11:02

标签: blackberry java-me

我正在尝试使用图片作为我的黑莓应用程序的背景而不是默认的白色背景。我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:1)

final Bitmap header_Bitmap = //your image
    VerticalFieldManager vfm_ = new VerticalFieldManager(
            Manager.NO_HORIZONTAL_SCROLL | Manager.NO_HORIZONTAL_SCROLLBAR
                    | Manager.NO_VERTICAL_SCROLL
                    | Manager.NO_VERTICAL_SCROLLBAR | Field.USE_ALL_WIDTH) {
        public void paint(Graphics graphics) {
            graphics.setBackgroundColor(0x040811);
            graphics.clear();
            graphics.drawBitmap(0, 0, header_Bitmap.getWidth(),
                    header_Bitmap.getHeight(), header_Bitmap, 0, 0);
            super.paint(graphics);
        }
    };
add(vfm_);

答案 1 :(得分:0)

背景 BackgroundFactory 可用于设置任何 VerticalFieldManager Horizo​​ntalFieldManager 的背景MainScreen 。自JDE版本 4.6.0 以来,此支持可用。

检查API

Bitmap bitmap = Bitmap.getBitmapResource("myBitmap.png");
Background background = BackgroundFactory.createBitmapBackground(bitmap);
setBackground(background);