4

I want to create a background for a screen that will not move when the screen is scrolled. My current code is something like:

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

However this will create a loose background, meaning that if screen fields stretch out of the display, when user scrolls the screen the background will move as well leaving some part of the screen background-less. I do not want to make the background repeat itself over and over for the stretched parts. What I do want however is a background that stays pinned to the display and the rest of the fields scroll on top of it. Do you know any direct or indirect way for doing this?

aligf
  • 2,020
  • 4
  • 19
  • 33

2 Answers2

4

Add the background to a manager that does not scroll. Add another manager to that to hold all of your fields and allow it to scroll. So it would be something like:

VerticalFieldManager noScroll = new VerticalFieldManager(VerticalFieldManager.USE_ALL_HEIGHT 
  | VerticalFieldManager.USE_ALL_WIDTH |  VerticalFieldManager.NO_VERTICAL_SCROLL 
  | VerticalFieldManager.NO_VERTICAL_SCROLLBAR);

VerticalFieldManager scroll = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
noScroll.add(scroll);
//Add all of your fields to scroll.
Jonathan
  • 1,735
  • 11
  • 17
-2

Use following code to set background of screen which have bitmap as background.

getMainManager().setBackground(BackgroundFactory.createBitmapBackground(bitmap));
Tariq M Nasim
  • 1,278
  • 11
  • 24
Sudhanshu
  • 11
  • 6