Using this to measure the height of each text gives different values and adjusts the xCLV pane's height fine.
However, the height of Label1 stays constant, although the height of the panel is dynamically adjusted.
Is the assumption wrong that "Label1.PrefHeight = intH" sets the height of the label once the panel has been created?
However, the height of Label1 stays constant, although the height of the panel is dynamically adjusted.


B4X:
Sub FillClv1
CustomListView1.Clear
Dim strText As String = ""
For i=1 To 10
strText = strText & " Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
Dim panX As Pane = CreatePanel( ((i *8) +2) & " words. " & strText, CustomListView1.AsView.Width, "i" & i)
CustomListView1.Add(panX , "j" & i)
Next
End Sub
Sub CreatePanel(Text As String, Width As Int, Value As String) As Pane
Log("#-")
Log("#-Sub CreatePanel, Text.len=" & Text.Length)
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, 48dip)
p.LoadLayout("Layout2")
Label1.Text = Text
'
Dim intH As Int = Floor(jMeasureMultilineTextHeight2(fx.DefaultFont(15), Width, Text))
Log("#- x48, jMeasureMultilineTextHeight2, intH=" & intH)
'
' ~- ~- ~- ~- ~- ~- ~- ~- ~- ~- ~-
' Expected behavior: Adjust the height of Label1 dynamically to the value of intH
' Observed behavior: The height of Label1 is constant, although the height of the panel is dynamically adjusted.
Label1.PrefHeight = intH ' <--- wrong ???
' ~- ~- ~- ~- ~- ~- ~- ~- ~- ~- ~-
'
p.Height = intH +30dip
Return p
End Sub
'
Sub jMeasureMultilineTextHeight2(Font As Font, Width As Double, Text As String) As Double
' Erel --> https://www.b4x.com/android/forum/threads/measure-multiline-text-height.84331/
Dim jo As JavaObject = Me
Return jo.RunMethod("MeasureMultilineTextHeight", Array(Font, Text, Width))
End Sub
#if Java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javafx.scene.text.Font;
import javafx.scene.text.TextBoundsType;
public static double MeasureMultilineTextHeight(Font f, String text, double width) throws Exception {
Method m = Class.forName("com.sun.javafx.scene.control.skin.Utils").getDeclaredMethod("computeTextHeight",
Font.class, String.class, double.class, TextBoundsType.class);
m.setAccessible(true);
return (Double)m.invoke(null, f, text, width, TextBoundsType.LOGICAL);
}
#End If
Is the assumption wrong that "Label1.PrefHeight = intH" sets the height of the label once the panel has been created?