I did a little test on LibGdx, on the Multi-Line Label, it seems that I can not get the wrapped line height. Below is the code. Theoretically, the height for aLebel should be> bLabel. But the result looks the same.
the code:
aLabel.setText("this is a super long long long text that need wrapping."); // line wrapped into 3 lines aLabel.setWrap(true); aLabel.setWidth(470); doLog("aLabel.getHeight(): " + aLabel.getHeight()); bLabel.setText("this is short."); // unwrapped line bLabel.setWrap(true); bLabel.setWidth(470); doLog("bLabel.getHeight(): " + bLabel.getHeight());
result:
aLabel.getHeight(): 45.0 bLabel.getHeight(): 45.0
Does anyone have any ideas how to get the actual multi-line growth in LibGdx? Thanks in advance.
. , , , .
public Label createLabel() { // Create label and set wrap Label label = new Label("Some long string here...", skin); label.setWrap(true); // Pack label label.pack(); // This might not be necessary, unless you're changing other attributes such as font scale. // Manual sizing label.setWidth(textWidth); // Set the width directly label.pack(); // Label calculates it height here, but resets width to 0 (bug?) label.setWidth(textWidth); // Set width again return label; }
LibGDX: 1.6.4
, , , Label . , , getHeight() , , .
, , BitWappedBound BitmapFont. , :
doLog("aLabel.getHeight(): " + aLabel.getStyle().font.getWrappedBounds(aLabel.getText(), aLabel.getWidth()).height);
, , :
Label label = new Label("Example", new Label.LabelStyle(font, Color.WHITE)); label.setWrap(true); Table table = new Table(); table.add(label).width(WITH);
For more information on how to use the table, go to: https://github.com/libgdx/libgdx/wiki/Table
The packet size of the widget corresponds to the size of the pref, nothing more. The width of the width of the label with the wrapper is 0.
Label label = new Label(...); label.setWrap(true); label.setWidth(123); label.setHeight(label.getPrefHeight());
Source: https://habr.com/ru/post/1545010/More articles:Record of dynamoDB OR status request? - amazon-dynamodbEntity Framework 6 and Effort (Entity Framework module testing tool) System.ArgumentException: string cannot have zero length - c #Bind sheet rows in a 3d array to make a 2d array - arraysWhat is the performance of Collections.binarySearch for manually searching a list? - javaRecursive in BNF Grammar - cNon-silent batch file del / s / q / f file - batch-fileHow to make a full boot sketch (for mobile devices and tablets) - twitter-bootstrapAndroid MediaPlayer: playing an audio resource in Raw based on URI - androidAndroid: choiceMode attribute in ListView navigation box - androidIdentifying duplicate numbers in an array - javaAll Articles