How to create a fixed background for the screen in Blackberry?

I want to create a background for the screen, which will not move when scrolling the screen. My current code looks something like this:

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

However, this will create a free background, which means that if the screen fields are stretched on the screen when the user scrolls the screen, the background will move and the rest of the screen will be smaller. I do not want the background to be repeated over and over for stretched parts. However, what I want is a background that remains attached to the display, and the rest of the fields scroll over it. Do you know any direct or indirect way to do this?

+4
source share
2 answers

Add a background to the manager that doesn't scroll. Add another manager to this to save all your fields and let it scroll. So it will 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. 
+4
source

Use the following code to set the background of the screen with the bitmap as the background.

 getMainManager().setBackground(BackgroundFactory.createBitmapBackground(bitmap)); 
-2
source

Source: https://habr.com/ru/post/1332249/


All Articles