java - Libgdx Label multiline text height -
java - Libgdx Label multiline text height -
i have done little test on libgdx, on multi-line label, seems cant wrapped line's height. next code. theoretically, height alebel should > blabel. result appear same.
code:
alabel.settext("this super long long long text need wrapping."); // line wrapped 3 lines alabel.setwrap(true); alabel.setwidth(470); dolog("alabel.getheight(): " + alabel.getheight()); blabel.settext("this short."); // unwrapped line blabel.setwrap(true); blabel.setwidth(470); dolog("blabel.getheight(): " + blabel.getheight());
result:
alabel.getheight(): 45.0 blabel.getheight(): 45.0
do have thought how actual multi-line height in libgdx? in advance.
i had same issue , seems there doesn't exist method in label class solve this. also, agree you, getheight() method should homecoming real height of actor, don't know if that's bug or there reasoning behind behaviour.
anyways, how solved issue using bitmapfont's getwrappedbounds method. it's not short, illustration following:
dolog("alabel.getheight(): " + alabel.getstyle().font.getwrappedbounds(alabel.gettext(), alabel.getwidth()).height);
java android libgdx label
Comments
Post a Comment