Fudge
07/15/2020, 8:43 PMgravity
modifier only allows aligning horizontally, but not vertically (and also can only be called when a Column is in scope which is very odd, I mean what do you do when the column is way up the tree?)Column(modifier = Modifier.fillMaxHeight()) {
Row(modifier = Modifier.fillMaxHeight()) {
child(modifier = Modifier.gravity(Alignment.Bottom))
}
}
(I would have expected it to look like this:)
Column(modifier = Modifier.fillMaxHeight()) {
child(modifier = Modifier.align(Alignment.Bottom))
}
nglauber
07/15/2020, 9:14 PMColumn(modifier = Modifier.fillMaxHeight(),
verticalArrangement=Arrangement.Bottom) {
Text("AAA")
}
Column(modifier = Modifier.fillMaxHeight()) {
Text("AAA")
Text("BBB")
Spacer(modifier = Modifier.weight(1f))
Text("CCC")
}
Fudge
07/15/2020, 9:18 PMColumn
is not in scope? I guess pass Column as a receiver ?nglauber
07/15/2020, 9:27 PMColumn {
SomeComponent()
Spacer(modifier = Modifier.weight(1f))
YourComponentThatNeedsAlignmentHere()
}
Fudge
07/15/2020, 9:49 PMColumn {
Text("bar")
AlignmentLogicComponent()
}
@Composable fun AlignmentLogicComponent() {
Spacer(modifier = Modifier.weight(1f)
Text("foo")
}
Column {
Text("bar")
AlignmentLogicComponent()
}
@Composable fun ColumnScope.AlignmentLogicComponent() {
Spacer(modifier = Modifier.weight(1f)
Text("foo")
}
Zach Klippenstein (he/him) [MOD]
07/15/2020, 10:02 PMColumnScope
as a receiver is the way to do thatAdam Powell
07/15/2020, 10:12 PMColumnScope
as a receiver to express the required context of where a composable will behave as expected is something I've been pretty excited about, since it addresses the long-standing type safety issues around view xml LayoutParamsandroid:layout_weight
isn't working because the parent changed in some refactor somewhereModifier.fillMaxHeight().wrapContentHeight(Alignment.Bottom)
instead of using the weighted spacer; dropping the fillMaxHeight from that will also let you only fill up until the min height is met if that's useful in the situationnglauber
07/16/2020, 12:26 AMColumnScope
, right? In this case you’ll be able to use AlignmentLogicComponent
inside of all Column
which I’m not sure it’s an expected behavior…
I like the idea though 🙂
Your solution sounds better @Adam Powell (I can’t figure out why 😛)Adam Powell
07/16/2020, 1:59 AMnglauber
07/16/2020, 2:39 AM