很容易创建按钮或按钮组,
Root root = iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer).
setStyles(make(VALIGN.top, HALIGN.right)).
setBounds(0, 0, width, height).
add(backButton);
However, I couldn t figure out how to create two button in different group, i.e. one button on TOP-LEFT and on button on TOP-RIGHT...
I tried created two root, one button will be disabled/un-clickable. if I crate one root, they will grouped together :(
============ Thanks samskivert for the detail answer, but I m not able produce the correct result. For the 1st suggestion in orginal answer, full code as below:
Font SMALL = PlayN.graphics().createFont("Helvetica", Font.Style.PLAIN, 24);
final Stylesheet ROOT = SimpleStyles.newSheetBuilder().
add(Element.class, make(FONT.is(SMALL))).
add(Button.class, make(BACKGROUND.is(Background.solid(100)))).create();
Group group = new Group(AxisLayout.vertical()).add(
new Group(AxisLayout.horizontal(), Style.HALIGN.left).add(
new Button("Upper left")),
AxisLayout.stretch(new Shim(1, 1)),
new Group(AxisLayout.horizontal(), Style.HALIGN.right).add(
new Button("Lower right")));
iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer)
.setBounds(0, 0, 960, 640)
.add(group);
it produce this screen (ie, it s all centered, instead of upper-left/lower-down...)
For the 2nd one, full code as below: Font SMALL = PlayN.graphics().createFont("Helvetica", Font.Style.PLAIN, 24);
final Stylesheet ROOT = SimpleStyles.newSheetBuilder().
add(Element.class, make(FONT.is(SMALL))).
add(Button.class, make(BACKGROUND.is(Background.solid(100)))).create();
Group group = new Group(new BorderLayout()).add(
new Group(AxisLayout.horizontal(), Style.HALIGN.left).
setConstraint(BorderLayout.NORTH).add(
new Button("Upper left")),
new Group(AxisLayout.vertical(), Style.HALIGN.right).
setConstraint(BorderLayout.SOUTH).add(
new Button("Lower right")));
iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer)
.setBounds(0, 0, 960, 640)
.add(group);
it produce this screenshot (ie, it s centered and overlap...)
再次感谢。