I would like to adjust the height of a label in a listview.
I found answers that recommend using the MeasureMultilineTextHeight of the StringUtils library, but I would like to avoid adding another library to my project.
Could someone extrapolate the function and add it to the Code snippets forum?
Dim cnv As Canvas
Dim lbl As Label = ListView1.TwoLinesLayout.SecondLabel
cnv.Initialize(lbl)
Dim CanvasStringHeight As Float
CanvasStringHeight = cnv.MeasureStringHeight(Note, lbl.Typeface, lbl.TextSize)
Log("CanvasStringHeight = " & CanvasStringHeight)
but I get this error: java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:603)
...
I think I get the error because I should refer to a specific item, but there is not a function to get it:
ListView.GetItem returns text (though there is RemoveAt, damn )
Manfred, that routine does the opposite, fits the text height of the label, unfortunately
btw: luca, you only can set ONE height for Label and one height for SecondLabel in Listview.
Every item in the listview will have the same height (ListView<X>.TwoLinesLayout.Label.Height+ListView<X>.TwoLinesLayout.SecondLabel.Height)
You cannot set an different heigth for every listview-item
and this will be adapted to fontsize, color and so on too. Every item will look the same. It´s like "Little boxes"
btw: luca, you only can set ONE height for Label and one height for SecondLabel in Listview.
Every item in the listview will have the same height (ListView<X>.TwoLinesLayout.Label.Height+ListView<X>.TwoLinesLayout.SecondLabel.Height)
You cannot set an different heigth for every listview-item
and this we be adapted to fontsize, color and so on too. Every item will look the same.