I have a HorizontalFieldManager with two buttons inside it. The buttons need to be placed on the far left and the far right of the screen, respectively. I know HorizontalFieldManager only puts them left-to-right, so i have to extend them.
Here is what I did, however it yields no fruit. The buttons do appear, but too small and with no text on them (Which I already set).
Here is my layout code.
protected void sublayout(int width, int height) {
setPositionChild(getField(0), 0, 0);
int fieldZeroWidth = Max(getField(0).getContentWidth(),getField(0).getPreferredWidth());
int fieldZeroHeight = Max(getField(0).getContentHeight(),getField(0).getPreferredHeight());
layoutChild(getField(0),
fieldZeroWidth,
fieldZeroHeight);
int fieldOneWidth = Max(getField(1).getContentWidth(),getField(1).getPreferredWidth());
setPositionChild(getField(1),
Display.getWidth() - fieldOneWidth,
0);
int fieldOneHeight = Max(getField(1).getPreferredHeight(),getField(1).getContentHeight());
layoutChild(getField(1),
fieldOneWidth,
fieldOneHeight
);
setExtent(Display.getWidth(), Max(getPreferredHeight(),fieldOneHeight,fieldZeroHeight));
}
After I create this custom manager, I add it at the bottom with setStatus() function.
I want the two buttons to appear on the opposite sides (which they do), however in the right size with their text displayed.
Thanks The Max functions just return the biggest between the arguments, obviously.
If u want to place the two field in the corners of the HorizontalFieldManager use this following code: