Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
ram_mohan
Posts: 10
Registered: 10-15-2011
My Carrier: xxx

how to Scroll a Bitmap image?

[ Edited ]

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?

Please use plain text.
Developer
arkadyz
Posts: 2,146
Registered: 07-08-2009
My Carrier: various

Re: how to Scroll a Bitmap image?

(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.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
maadani
Posts: 552
Registered: 05-04-2011

Re: how to Scroll a Bitmap image?

[ Edited ]

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.

Please use plain text.
Developer
jitendrasharma
Posts: 205
Registered: 08-04-2009

Re: how to Scroll a Bitmap image?

You can follow the below knowledge base article to achieve the same:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-scrollable-image-field/ta-p/444955

 

Please use plain text.
Contributor
ram_mohan
Posts: 10
Registered: 10-15-2011
My Carrier: xxx

Re: how to Scroll a Bitmap image?

Hey thanks a lot  all  for the response.

Really appreciate it.

Please use plain text.