对齐libgdx TextButton中剩余的文本

时间:2014-06-05 20:28:27

标签: java json libgdx scene2d

有没有办法将文本按钮中的文本对齐到左(或右)而不是中心?我找了它,但我似乎无法找到它。你可以用.json皮肤文件做些什么,如果有,怎么做?

谢谢,如果我不高兴,请告诉我:)

2 个答案:

答案 0 :(得分:11)

是的,您可以将文本对齐到按钮的左侧,请参阅示例:

someButton.getLabel().setAlignment(Align.left);

所以基本上你必须将按钮的标签对准按钮内的左侧。显然你可以做同样的右,顶部,底部对齐等。

答案 1 :(得分:0)

这也做同样的事情,"调整标签位置"。

    Skin theSkin= new Skin();  
//Create a button style
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.pressedOffsetY=-4.0f;
    textButtonStyle.unpressedOffsetY=-4.0f;
theSkin.add("default", textButtonStyle);
TextButton   theButton = new TextButton("New",theSkin);
相关问题