it defaults to fitting both the <width and height>...
# doodle
it defaults to fitting both the width and height of the label’s text. make sure you’re not setting it to a value of setOf(
) anywhere. happy to review any minimum repro you have if you think it’s a bug though.
Just to be finally clear lol. Does a label require size like other views?? If yes, I think it's not a bug, If no,
does give a label a default size based on the text. But im still investigating this. So after digging deeper, heights are fine, but widths return zero.
This only happens if
is true. So if wrap words is false, the width is returned.
Dunno if that is intended.
Copy code
val text = Label("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.").apply {
    foregroundColor = Red
    wrapsWords = true

display += text

display.layout = Layout.simpleLayout {
    var y = 0.0
    it.children.forEach { view ->
        view.bounds = Rectangle(0.0,y, view.width, view.height)
        y += view.height
figures out it’s size by calling
on its `behavior`; the behavior honors
and tells the label what size to take based on that, the text, and wrapping. so you need a
installed for any of this to work. the default logic is to set the size to that of the text when there is no wrapping. you can see how
handles measureText. with
wrapText = true
, there needs to be some width to wrap at, so
(used for all text measurement) requires a width to determine the text height when it is wrapped at that width. otherwise there’s no way to say how much space the text takes up, other than what its size would be if it were on a single line (i.e. no wrapping). so the label NEEDS a
specified to correctly measure its height when wrapping is enabled. you also need to keep
so the label retains that size of course; but that’s the default behavior if you don’t change
. let me know if that clarifies things and if this is the behavior you’re seeing.
Yeah, this is the behavior I'm seeing. Which makes sense.