Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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

getMainManager().setBackground(BackgroundFactory.createBitmapBackground(bitmap));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top