12-25-2011 05:49 AM - last edited on 12-25-2011 05:49 AM
Hi,
(i) I have an (large)bitmap image which needs to be scrolled to the bottom.
I have used
VerticalFieldManager vm2 = new VerticalFieldManager(FOCUSABLE | VERTICAL_SCROLL | VERTICAL_SCROLLBAR)
But it doesn't work!
Is there any way to do it?
(ii) How to place images on a background at specified positions on the screen.
I have used
width = Display.getWidth();
setPadding(0,0,0,width/2);
to accomplish this but the problem is that it appears at different positions in different phones(8900,9550,etc.). Is there any alternative that can be applied to all blackberry devices?
12-25-2011 11:41 AM
(i) I imagine you also have a BitmapField with that image, added to the manager (vm2.add(yourBitmapField)).
By using a VFM with VERTICAL_SCROLL, you achieve an almost infinite available height for your BitmapField.
However, you haven't automatically enabled scrolling past that BitmapField. There are several ways:
- use BlackBerry autoscroll: when a field gets focus, the containing manager scrolls to make sure the field is visible. You may add a NullField after your BitmapField and it will serve as an "anchor" for the scroll-to-bottom position (and, if you want to be able to get back to the top of the image, add a NullField before your BitmapField as well). The downside of this is inability to position in the middle of your image (what if it is 3 screens tall?)
- scroll your vm2 programmatically: vm2.setVerticalScroll(newPosition) is the call you need. Make your newPosition calculations inside, say, navigationMovement. Check the on-screen manager height using getVisibleHeight and the full one using getVirtualHeight.
(ii) Images on the background aren't fields, so they won't care about your padding. Or are you adding BitmapFields? Then they are not on the background (you can't place other fields over them).
Anyway, setPadding does not tell the Manager the exact positions where it can put the fields - it only adds some limitations. If you want to specify the positions of the images yourself, take a look at AbsoluteFieldManager (despite being documented since 6.0.0 it is available since 5.0.0). Also check FIELD_LEFT, FIELD_HCENTER and FIELD_RIGHT style bits (specified on the fields, used by the containing manager) - they might be all you need.
12-25-2011 02:21 PM - last edited on 12-25-2011 02:22 PM
Hi @ram_mohan
I'm maybe missing something, but I think that for your second question you can use the Screen.paintBackground function and there call the Graphic.drawBitmap function.
The drawBitmap allows you set the starting point (x,y) which will help to place it on a specific location on the screen.
Note: remember that different devices have different resolutions so pixels will have different sizes on the different devices.
E.
12-26-2011 12:49 AM
You can follow the below knowledge base article to achieve the same:
http://supportforums.blackberry.com/t5/Java-Develo
12-31-2011 12:13 AM
Hey thanks a lot all for the response.
Really appreciate it.