Guru Karthi R
Guru Karthi R

Reputation: 320

How to mention dimensionRation for ConstraintLayout with jetpack compose?

We have app:layout_constraintDimensionRatio for ConstraintLayout while using in with XML. Likewise, how to use dimensionRatio with jetpack compose.

Upvotes: 1

Views: 191

Answers (1)

Stefano Sansone
Stefano Sansone

Reputation: 2709

Try with aspectRatio, you need to import

import androidx.compose.foundation.layout.aspectRatio

and then use it as follow

Box(modifier = Modifier.aspectRatio(0.5f))

Upvotes: 1

Related Questions