Question

I have a simple background layer:

@Override
public void wasAdded() {
    super.wasAdded();

     Image bgImage = PlayN.assets().getImage("images/Welcome.png");
     ImageLayer bgLayer = graphics().createImageLayer(bgImage);
     layer.add(bgLayer);

     Image usernameButton =
     PlayN.assets().getImage("images/textField.png");
     ImageLayer usernameLayer =
     graphics().createImageLayer(usernameButton);
     usernameLayer.setTranslation(197, 337);
     layer.add(usernameLayer);

    }
}

And I would like to add a Text field element to a specific position (over the username image).

final Field field = new Field();
field.text.update("your name");

How can I achieve this ? Thanks.

Was it helpful?

Solution

I need to create an AbsoluteLayout root and add the group at the specific position:

_root = iface.createRoot(new AbsoluteLayout(), SimpleStyles.newSheet(), layer);
_root.setSize(width(), height());
Group group = new Group(new AbsoluteLayout()).add(AbsoluteLayout.at(new Field("username"), 197, 337));
_root.add(AbsoluteLayout.at(group, 0, 0));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top