https://kotlinlang.org logo
#compose
Title
# compose
o

oday

12/10/2021, 7:03 AM
any reason why I can’t find the
weight
Modifier? just goes unresolved, no hint to import or anything, using Compose
1.0.5
z

Zoltan Demant

12/10/2021, 7:05 AM
Its only available inside the
content
block for Column/Row by way of their scopes. The scope provides this function
Copy code
@Stable
fun Modifier.weight(
    /*@FloatRange(from = 0.0, fromInclusive = false)*/
    weight: Float,
    fill: Boolean = true
): Modifier
o

oday

12/10/2021, 7:06 AM
yea like here
Copy code
Column(modifier = Modifier.weight(1f)) {
            Text(text = "Hello")
            Text(text = name)
        }
right?
t

Tin Tran

12/10/2021, 7:07 AM
Copy code
Column() {
            Text(text = "Hello", Modifier.weight(1f))
            Text(text = name, Modifier.weight(1f))
        }
Like this
m

maciejciemiega

12/10/2021, 7:08 AM
No, inside the
{ }
of a Column. Unless your Column is in another Column (or Row)
o

oday

12/10/2021, 7:08 AM
then the tutorial is outdated
m

maciejciemiega

12/10/2021, 7:09 AM
In the tutorial that Column that uses weight modifier is in a Row, so everything is fine
o

oday

12/10/2021, 7:09 AM
no, I’m blind, they placed the whole thing in a Row and then accessed weight
🕵️‍♂️ 1
👍 1
yea just like in normal views
27 Views