04-25-2011 12:46 PM
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!
Solved! Go to Solution.
04-25-2011 01:02 PM
If your target 5+ OS I would use AbsoluteFieldManager and calculated position myself.
Thanks,
Eugen
04-25-2011 01:11 PM
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!
04-28-2011 04:09 PM
Thanks arkadyz! After playing with this a bit I got it to work ![]()