开发者

How to create a fixed background for a Screen in Blackberry?

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 pi开发者_开发百科nned 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?


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.


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

getMainManager().setBackground(BackgroundFactory.createBitmapBackground(bitmap));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜