gpt4 book ai didi

android - 在 Textbutton 中调整文本大小

转载 作者:太空狗 更新时间:2023-10-29 16:41:00 25 4
gpt4 key购买 nike

大家好!我正在尝试使用 libgdx 和 scene2d 设置 TextButton 中文本的大小。

下面是我如何创建和初始化文本按钮对象:

Skin skin = new Skin();
skin.add("white", new Texture(Gdx.files.internal("data/texture.jpg")));
skin.add("default", new BitmapFont());

TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.up = skin.newDrawable("white");
textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY);
textButtonStyle.checked = skin.newDrawable("white", Color.BLUE);
textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);
textButtonStyle.font = skin.getFont("default");
skin.add("default", textButtonStyle);

TextButton newGame = new TextButton("Hello button",skin);

之后,完美创建了包含文本的按钮,但我不明白如何更改它的文本大小。

我已经尝试了 Label 对象的几乎所有方法:

newGame.getLabel().setScale(10);
newGame.getLabel().setWidth(100);

等等。所以我的问题是:如何更改 TextButton 中的文字大小

最佳答案

尝试将字体比例设置为 Button 的标签。

tb.getLabel().setFontScale(5.0f);

关于android - 在 Textbutton 中调整文本大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17785463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com