Welcome!

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
berkvens852
Posts: 38
Registered: ‎05-26-2010
My Carrier: Rogers
Accepted Solution

Using HorizontalFieldManager inside VerticalFieldManager

Hello, I'm looking to center a button on the middle of the screen. From what I've seen I should be able to do this by adding the HorizontalFieldManager into the VerticalFieldManager:

 

HorizontalFieldManager mensButton =

new HorizontalFieldManager(Field.FIELD_HCENTER);

 

VerticalFieldManager mensButton2 =

new VerticalFieldManager(Field.FIELD_VCENTER);

 

mens

= new ButtonField("Mens Sports");

 

mensButton2.add(mensButton);

 

mensButton2.add(mens);

 

For some reason this only centers the button horizontally, and not vertically. I've tried tried inculdign USE_ALL_HEIGHT, but still doesn't work. Any ideas?

 

Thanks!

Please use plain text.
Developer
Eugen
Posts: 466
Registered: ‎07-16-2009
My Carrier: Vodafone NL

Re: Using HorizontalFieldManager inside VerticalFieldManager

If your target 5+ OS I would use AbsoluteFieldManager and calculated position myself.

 

Thanks,

Eugen

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

Re: Using HorizontalFieldManager inside VerticalFieldManager

Few things:

1) You indeed need your HFM to have USE_ALL_HEIGHT.

2) Since your Screen most probably has a VerticalFeildManager as a delegate (or a main manager, in case of MainScreen), add mensButton2 to mensButton and mensButton to the Screen, not the other way around.

3) If you use MainScreen, make sure it has NO_VERTICAL_SCROLL style bit!

 

Anyway, this question has been asked so many times it's not even funny. Unfortunately, it's not easy to use "Search" feature for this - "center screen" or "middle screen" or other stuff brings way too many articles, most of which are irrelevant.

I've recently gave some detailed explanation about this, though - look at this post:

How to center horizontally and vertically...

 

Good luck!

 


----------------------------------------------------------
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.
Contributor
berkvens852
Posts: 38
Registered: ‎05-26-2010
My Carrier: Rogers

Re: Using HorizontalFieldManager inside VerticalFieldManager

Thanks arkadyz! After playing with this a bit I got it to work :smileyhappy:

Please use plain text.