【问题标题】:Align text left in libgdx TextButton在 libgdx TextButton 中左对齐文本
【发布时间】:2014-07-27 00:09:21
【问题描述】:

有没有办法将文本按钮中的文本向左(或向右)而不是居中对齐?我一直在寻找它,但我似乎找不到它。是否可以使用 .json 皮肤文件进行操作,如果可以,如何操作?

谢谢,如果我不准确,请告诉我:)

【问题讨论】:

    标签: java json libgdx scene2d


    【解决方案1】:

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

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

    所以基本上你必须将按钮的标签与按钮内的左侧对齐。显然你可以对右、上、下对齐等做同样的事情。

    【讨论】:

      【解决方案2】:

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

          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);
      

      【讨论】:

        猜你喜欢
        • 2022-11-01
        • 2014-12-31
        • 2015-02-12
        • 1970-01-01
        • 2014-12-12
        • 2022-07-27
        • 1970-01-01
        • 2019-10-01
        • 1970-01-01
        相关资源
        最近更新 更多