In LibGDX, I want to add some long text content to several Labels. I'm creating those labels in a loop, and the text content is different in each iteration. I want the Label
to have a size that fits the text exactly. Is there a way to do this? I did setWrap(true)
to the Label.
For reference, consider a Label:
+------------------+
| |
+------------------+
One copy of that may be:
+------------------------------------+
| Lorem ipsum dolor sit amet, |
| consectetur adipiscing elit. |
| Nec vero alia sunt quaerenda |
| contra Carneadeam illam sententiam.|
+------------------------------------+
Another one should resize to the content:
+------------------------------------+
| Uterque enim summo bono fruitur, |
| id est voluptate. Illud non |
| continuo, ut aeque incontentae. |
| Occultum facinus esse potuerit, |
| gaudebit; Multoque hoc melius nos |
| veriusque quam Stoici. Id Sextilius|
| factum negabat. Ita nemo beato |
| beatior. |
+------------------------------------+
EDIT:
Please note that the horizontal wrapping is working perfectly. I need the Label size to adjust with the text content vertically. Width is fixed. Height is not.