androidkotlinandroid-jetpack-compose

Where is weight (in jetpack compose)?


Updated to Jetpack Compose a-08 today and have a problem. In previous builds I used weight modifier, but now i can't find it. What happened or what is the alternative? In changelogs I founded no information about it.


Solution

  • You can still find it there, but the weight modifier is a extension function inside RowScope and inside ColumnScope, which means you can only use it inside a Column or a Row.

    Reference to RowScope: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/RowScope#weight

    Reference to ColumnScope: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/ColumnScope#weight