A
A
Andrey Begin2018-07-25 17:24:48
Java
Andrey Begin, 2018-07-25 17:24:48

How to create text in Java-android project (libGDX)?

So, you need to create a text field in an Android project using the libGDX library.
Task:
1. Fit the desired size of the text
2. Change the background (font)
3. Colors
Before that, I sat on AS3 + Starling, where such a thing was done through TextFormat, which was quite easy to write.
I did not find the necessary information on the Internet, although in fact there should be a million articles with examples with such a "childish" function - as for me. I found a couple of videos where they showed that you need to create a separate "skin" for the text, saving the font file in the .fnt format, where the size is also set.
However, in this case, the text is created, but in order to change the same size, you need to do the operation again ( create .fnt), which in my understanding looks very stupid.
Is it really so simple in the same Flash, you create text in code, you also set both the font and the background there.
And here, in order to at least create this text, you need to do a "million" operations with files.
Therefore, I think that after all, I misunderstood something, and plain text can be created in an easy way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-07-25
@asmailiks

If you need text as a GUI element then this:
https://github.com/libgdx/libgdx/wiki/Scene2d.ui
Displaying text with Lablel
https://github.com/libgdx/libgdx/wiki/Scene2d.ui# label
Or you can directly render https://github.com/libgdx/libgdx/wiki/Bitmap-fonts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question