Resize text to fit label in libGDX

I am adding a Label object with some text to the stage. Before that, I change the label width, height, etc. The problem I'm running into is that the text never changes to match the label. Is there a way to make the text fit the label size?

code:

 LabelStyle labelStyle = new LabelStyle(font,Color.BLACK);
 label = new Label("HI!",labelStyle);
 label.setPosition(0,0);
 label.setScale(100,100);
 stage.addActor(label);

      

+3


source to share


1 answer


I also think it would be nice to add some code, maybe it will help you

https://github.com/libgdx/libgdx/wiki/Scene2d.ui



"invalidate invalidateHierarchy"

new look at https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelScaleTest.java

0


source







All Articles