After scaling down "Forgot Password:(" button, seems like its cell did not scale down. The result for that is that cell contents are in the bottom left of the cell. I need it to be aligned to the center or I need to scale down the cell to content's size.
And the code:
Table tableRoot = new Table();
tableRoot.setFillParent(true);
tableRoot.padTop(40);
tableRoot.align(Align.center);
final Label hint = new Label("Wrong password", Utility.UI_SKIN, "default-text");
hint.setAlignment(Align.center);
hint.setFontScale(1.3f);
final Label question = new Label("Return to login screen?", Utility.UI_SKIN, "default-text");
question.setAlignment(Align.center);
Table table = new Table();
final TextButton yesButton = new TextButton("Yes", Utility.UI_SKIN, "login-window-button");
final TextButton forgotButton = new TextButton("Forgot password:(", Utility.UI_SKIN, "login-window-button");
forgotButton.setTransform(true);
forgotButton.setScale(0.7f);
table.add(yesButton).pad(10).row();
table.add(forgotButton).pad(10).align(Align.center); //align here does not work
tableRoot.add(hint).growX().row();
tableRoot.add().grow().row();
tableRoot.add(question).growX().padBottom(20).row();
tableRoot.add(table).growX().row();
tableRoot.add().grow().row();
tableRoot.add().grow().row();
tableRoot.pack();
What have I done wrong or missed?
Scaling an Actor does not adjust its preferred size. You have many ways to face this, choose the one you like the most.
forgotButton.setOrigin(Align.center)
forgotButton.getLabel().setFontScale(.7f)
table.add(forgotButton).pad(10).prefWidth(forgotButton.getPrefWith() * .7f)