Search code examples
layoutblackberry

UI is not fixed on painting the background in VerticalFieldManager in BlackBerry?


I have prepared a screen in which I am allowing user to create an account. as shown in the first image I have used an image(bg_BB.png image) as MainScreen Background, after that i have taken another VFM and painting that white Background (white_bg2.png)on that vertical field manager and ADDING ALL MY FIELD ON THAT VFM.

But the problem arises when the keyboard is pops-up. All the fields apears to be floating over the background as shown in the second pic.

Below is the code which I am using:

Bitmap backGroundImage = Bitmap.getBitmapResource("bg_BB.png");
((VerticalFieldManager) getMainManager()).setBackground(BackgroundFactory.createBitmapBackground(backGroundImage));

final Bitmap tabBackGroundImage = Bitmap.getBitmapResource("white_bg2.png");

_mainVfm = new VerticalFieldManager(Field.USE_ALL_WIDTH) {

    protected void paint(Graphics graphics) {
        int y = CreateUserAccountScreen.this.getMainManager().getVerticalScroll();
        graphics.drawBitmap(0, y, 
                            tabBackGroundImage.getWidth(), 
                            tabBackGroundImage.getHeight(), 
                            tabBackGroundImage, 
                            0, 0 );

        super.paint( graphics );
    }
};

enter image description here enter image description here


Solution

  • replace your code with:

    Bitmap tabBackGroundImage = Bitmap.getBitmapResource("white_bg2.png");
    VerticalFieldManager _mainVfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | 
              Manager.VERTICAL_SCROLLBAR|
              Manager.USE_ALL_WIDTH);
    _mainVfm.setBorder( BorderFactory.createBitmapBorder(
                   new XYEdges(12,12,12,12), tabBackGroundImage
           )
    );     

    make sure that your border image have white background.
    i use this method and it works perfectly.