For placing a Field (for example HorizontalFieldManager) in center of the screen simple setting margin will do the trick.
Here is an example of placing a HorizontalFieldManager in the center.
HorizontalFieldManager hfm = new HorizontalFieldManager(); LabelField testLabel1 = new LabelField( "Test Label1"); LabelField testLabel2 = new LabelField( "Test Label2"); hfm.add(testLabel1); hfm.add(testLabel2); int leftEmptySpace = (Display.getWidth() - hfm.getPreferredWidth()) / 2; int topEmptySpace = (Display.getHeight() - hfm.getPreferredHeight()) / 2; hfm.setMargin(topEmptySpace, 0, 0, leftEmptySpace); //now add this manager to MainScreen this.add(hfm);
|
Thanks, really helped
ReplyDelete