Reputation: 31
In a libgdx dialog I want to display three text lines, with a button to quit the dialog at the bottom.
The following code would print all text in 1 line, followed by the button at the bottom:
Dialog dialog = new Dialog("Stats", skin);
dialog.text("First line");
dialog.text("Second line");
dialog.text("Third line");
dialog.button("Done");
dialog.show(stage);
If I use table followed by a button like the following, the button would be shown at the left side not the bottom.
Table table = new Table(skin);
table.add(new Label("First line", skin));
table.row();
table.add(new Label("Second line", skin));
table.row();
table.add(new Label("Third line", skin));
Dialog dialog = new Dialog("Stats", skin);
dialog.add(table);
dialog.button("Done");
dialog.show(stage);
If I put a button inside the table the dialog can't be clicked close.
Upvotes: 2
Views: 1397
Reputation: 11
If you want to do it by table. Try
dialog.getContentTable().add(table);
If you want a text dialog. Follow this
Label text = new Label("first line\nsecond line\nthird line \n",skin,labelStyle);
text.setWrap(true);
Upvotes: 1