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

Yuriy Kulikov

07/18/2020, 1:44 PM
Hello everyone, can someone help me with a layout for a list row? I cannot wrap my head around it. I have a Row, which has 2 child Columns. First Column has a Text. The second Column has a Switch and a Text. The height of the Row should be defined by the height of the first column. I would like to make Switch and the Text in the second Column to have equal weights and to stretch. Can I achieve this with current state of Compose? Thank you.
j

Jorge Castillo

07/18/2020, 1:49 PM
If you can send a draft or something it'd be easier to help 👍
y

Yuriy Kulikov

07/18/2020, 1:52 PM
Code or image?
@Jorge Castillo Is this is what you had in mind as draft? 🙂
j

Jorge Castillo

07/18/2020, 2:12 PM
Yeah thanks. I'll try something.
What about something like this?
y

Yuriy Kulikov

07/18/2020, 2:26 PM
Awesome! Thank you!
I will take your solution as a basis and will work from there🙂
It worked well 🙂 Unfortunately, ConstraintSet is deprecated in dev14. Going to look into ConstraintLayoutDemo and DemoInlineDSL which are mentionen in dev14 KDoc.
j

Jorge Castillo

07/18/2020, 4:04 PM
Right. I didn't even look at what version I was using at that project. But I bet there are equivalents in dev14 if that's the case.
y

Yuriy Kulikov

07/18/2020, 4:07 PM
I ended up doing it this way:
Copy code
modifier = Modifier
  .constrainAs(weekDaysText) {
    top.linkTo(timeText.bottom)
    start.linkTo(parent.start)
    end.linkTo(switch.start)
    bottom.linkTo(parent.bottom)
    width = Dimension.fillToConstraints
  }
Copy code
constrainAs is available in ConstaintLayoutScope
j

Jorge Castillo

07/18/2020, 4:18 PM
Awesome
4 Views