我想布局3 VerticalFieldManager
与屏幕NO_VERTICAL_SCROLL
。 一位经理应当与TOP,一要对齐底部,最后一个要消耗前两者之间的高度的其余部分。
是否可以无需重写实现sublaout()
对任何管理器? 我想达到的结果是:
我layouted这个屏幕下面的代码。 问题是,我是不是能够做到这一点没有覆盖sublayout()。
public class LayoutSandboxScreen extends MainScreen {
public LayoutSandboxScreen() {
super(NO_VERTICAL_SCROLL);
VerticalFieldManager vfmTop = new VerticalFieldManager(USE_ALL_WIDTH);
vfmTop.setBackground(BackgroundFactory.createSolidBackground(Color.GREEN));
vfmTop.add(new ButtonField("TOP", FIELD_HCENTER));
final VerticalFieldManager vfmCenter = new VerticalFieldManager(USE_ALL_WIDTH);
HorizontalFieldManager hfmCenter = new HorizontalFieldManager(USE_ALL_HEIGHT | FIELD_HCENTER);
vfmCenter.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
hfmCenter.add(new ButtonField("CENTER", FIELD_VCENTER));
vfmCenter.add(hfmCenter);
final VerticalFieldManager vfmBottom = new VerticalFieldManager(USE_ALL_WIDTH);
vfmBottom.setBackground(BackgroundFactory.createSolidBackground(Color.BLUE));
final ButtonField btn = new ButtonField("BUTTOM", FIELD_HCENTER);
vfmBottom.add(btn);
VerticalFieldManager vfmSecond = new VerticalFieldManager(USE_ALL_HEIGHT) {
protected void sublayout(int maxWidth, int maxHeight) {
setExtent(maxWidth, maxHeight);
layoutChild(vfmBottom, maxWidth, maxHeight);
int bottomHeight = vfmBottom.getHeight();
layoutChild(vfmCenter, maxWidth, maxHeight - bottomHeight);
setPositionChild(vfmCenter, 0, 0);
setPositionChild(vfmBottom, 0, maxHeight - bottomHeight);
}
};
vfmSecond.add(vfmBottom);
vfmSecond.add(vfmCenter);
add(vfmTop);
add(vfmSecond);
}
}