Background image scrolling disabled in blackberry main field manager

There is one MainScreen in my application. This screen contains many Vertical and Horizontal field managers, and all content is displayed successfully by scrolling.

This is my main VerticalFieldmanager code.

 vfm_Main = new VerticalFieldManager() { public void paint(Graphics g) { g.setColor(Color.WHITE); g.drawBitmap(0,0,mybackgroundImage.getWidth(),mybackgroundImage.getHeight(),mybackgroundImage,0,0); super.paint(g); } protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(Display.getWidth(),Display.getHeight()); setExtent(Display.getWidth(),Display.getHeight()); } }; 

There is one background image for this screen. When I look at this screen to see the full content of this screen, my background image also scrolls along with the content. For this reason, the background image looks so blurry and it repeats at the bottom of the screen.

I want to scroll only the contents of this screen. How to implement this?

I tried a lot, but did not get any tips and hits to prevent this? if anyone comes across this problem or have any idea please help me ...

Thanks in advance!

0
source share
2 answers

You need to do the following:

 vfm_Main = new VerticalFieldManager() { public void paint(Graphics g) { g.setColor(Color.WHITE); g.drawBitmap(0,0,mybackgroundImage.getWidth(),mybackgroundImage.getHeight(),mybackgroundImage,0,0); super.paint(g); } protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(Display.getWidth(),Display.getHeight()); setExtent(Display.getWidth(),Display.getHeight()); } }; subver=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR) { protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(Display.getWidth(),Display.getHeight()-3);//here we scroll the inner vertical setExtent(Display.getWidth(),Display.getHeight()-3); } } //Write all the code here; subver.setpadding(1,0,0,0); vfm_main.add(subver); add(vfm_Main); 

Like this image:

Vertical scrolling

Enough;

+1
source

I also once encountered one problem. I fixed it using 2 field managers like this.

 VerticalFieldManager mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR ) { public void paint(Graphics graphics) { graphics.clear(); graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backgroundBitmap, 0, 0); super.paint(graphics); } }; //this manager is used for adding the componentes VerticalFieldManager subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR ) { protected void sublayout( int maxWidth, int maxHeight ) { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); super.sublayout( displayWidth, displayHeight); setExtent( displayWidth, displayHeight); } }; 
0
source

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


All Articles