Lilly
04/14/2022, 12:07 AMColumn
? For example:
Column(modifier = Modifier.fillMaxWidth().height(80.dp).padding(12.dp)) {
Text("Text1")
Text("Text2")
// At bottom
Button(onClick = {}) {
Text("Click")
}
}
Colton Idle
04/14/2022, 12:38 AMtad
04/14/2022, 12:38 AMSpacer(Modifier.weight(1f))
Colton Idle
04/14/2022, 12:39 AMColton Idle
04/14/2022, 12:40 AMtad
04/14/2022, 12:41 AMweight(1f, fill = false)
)tad
04/14/2022, 12:42 AMtad
04/14/2022, 12:43 AM0f
but I'm not sureLilly
04/14/2022, 12:46 AMSpacer(Modifier.weight(1f))
it fills the whole screen. weight(1f, fill = false)
does nothing and 0f
is not valid (can't be build because of an preview issue).
Column(horizontalAlignment = Alignment.End) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = creationDate,
textAlign = TextAlign.End,
style = MaterialTheme.typography.caption
)
}
Spacer(modifier = Modifier.height(8.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = iconRes(R.drawable.ic_baseline_circle_24),
modifier = Modifier.size(12.dp),
tint = Yellow600,
contentDescription = null,
)
Spacer(modifier = Modifier.width(4.dp))
Text(text = "In Progress", color = Yellow600)
}
Spacer(Modifier.weight(1f))
Button(onClick = { /*TODO*/ }) {
Text(text = "Upgrade")
}
}
Lilly
04/14/2022, 12:47 AMColton Idle
04/14/2022, 12:48 AMIs it possible to place 2 children as normal at the top and one child at the bottom in a?Column
tad
04/14/2022, 12:48 AMColton Idle
04/14/2022, 12:48 AMLilly
04/14/2022, 12:51 AMColumn
while the height of the column is measured by its content (in my case the comment)Lilly
04/14/2022, 12:54 AMSpacer(Modifier.height(30.dp))
Lilly
04/14/2022, 12:55 AMtad
04/14/2022, 12:56 AMIntrinsicSize
, one sectad
04/14/2022, 12:58 AMModifier.height(IntrinsicSize.Min)
on the containing Row
tad
04/14/2022, 12:58 AMColton Idle
04/14/2022, 12:58 AMtad
04/14/2022, 1:00 AMBarrier
?)Lilly
04/14/2022, 1:02 AMtad
04/14/2022, 1:05 AMLilly
04/14/2022, 1:16 AMColumn(modifier = Modifier.fillMaxWidth().height(IntrinsicSize.Min)) {
...
Column(horizontalAlignment = Alignment.End) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = creationDate,
textAlign = TextAlign.End,
style = MaterialTheme.typography.caption
)
}
Spacer(modifier = Modifier.height(8.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = iconRes(R.drawable.ic_baseline_circle_24),
modifier = Modifier.size(12.dp),
tint = Yellow600,
contentDescription = null,
)
Spacer(modifier = Modifier.width(4.dp))
Text(text = "In Progress", color = Yellow600)
}
Spacer(Modifier.weight(1f))
Button(onClick = { /*TODO*/ }) {
Text(text = "Upgrade")
}
}
}
tad
04/14/2022, 1:18 AMRow
so the children will be aligned without overlappingLilly
04/14/2022, 1:18 AMtad
04/14/2022, 1:19 AMLilly
04/14/2022, 1:21 AM.height(IntrinsicSize.Min)
to the Row with the left and right Column but unfortuantely same result as in screenshot abovetad
04/14/2022, 1:21 AMLilly
04/14/2022, 1:24 AMLilly
04/14/2022, 1:32 AMSpacer(Modifier.weight(1f, fill = false))
it has still this extra space. Might this be a bug?tad
04/14/2022, 1:34 AMtad
04/14/2022, 1:36 AM.padding
to after .height(IntrinsicSize.Min)
?Lilly
04/14/2022, 1:39 AMtad
04/14/2022, 1:47 AMtad
04/14/2022, 1:48 AMtad
04/14/2022, 1:49 AMIntrinsicSize
measurement.tad
04/14/2022, 1:49 AMLilly
04/14/2022, 1:52 AMtad
04/14/2022, 1:53 AMtad
04/14/2022, 1:54 AMLilly
04/14/2022, 1:56 AMtad
04/14/2022, 1:56 AMtad
04/14/2022, 1:57 AMwrapContentSize
, lemme try thattad
04/14/2022, 2:15 AMtad
04/14/2022, 2:15 AMCompositionLocalProvider(LocalMinimumTouchTargetEnforcement provides false) {
Button(
onClick = { /*TODO*/ },
Modifier
.height(0.dp)
.wrapContentHeight(Alignment.Bottom, unbounded = true)
.heightIn(ButtonDefaults.MinHeight)
) {
Text(text = "Upgrade")
}
}
tad
04/14/2022, 2:17 AMtad
04/14/2022, 2:18 AMLilly
04/14/2022, 2:19 AMChris Sinco [G]
04/14/2022, 7:36 AMModifier.align(Alignment.Bottom)
for the Button? That should allow you to break alignment with the natural flow of siblings in the Column, but still keep the Column itself measured to the total height of its children.Chris Sinco [G]
04/14/2022, 7:43 AMLilly
04/14/2022, 10:02 AMModifier.align(Alignment.Bottom)
is not applicable:
fun Modifier.align(alignment: Alignment.Vertical): Modifier' can't be called in this context by implicit receiver. Use the explicit one if necessaryThe second suggestion does not work because none of the columns has set a height and naturally the column wraps its content, so a
verticalArrangement
modifier has no effect.
You missed that the Button
should be at the Bottom of the parent Row
and not at the Bottom of the right Column
which height is constrained to its content. So to make it work the right Column has to fill up the available space of the Row
while the left Column
specifies the height of the Row by its content.Lilly
04/14/2022, 10:34 AM@Preview
@Composable
fun TestPreview() {
Column(modifier = Modifier.fillMaxWidth().border(width = 1.dp, color = Color.Red)) {
Row(
modifier = Modifier
.height(IntrinsicSize.Min)
.fillMaxWidth()
) {
Column(modifier = Modifier.fillMaxWidth(0.6f)) {
Text(modifier = Modifier.border(width = 1.dp, color = Color.Red), text = "Short Text")
}
}
}
}
Where does the additional space below the Text
come from?Chris Sinco [G]
04/14/2022, 11:52 AMChris Sinco [G]
04/14/2022, 11:54 AMweight
to tell the measuring how to use the remaining free space. I also played around with removing that last Spacer you added to push the Button down, by adding verticalArrangement = Arrangement.SpaceBetween, which works since the Column now takes up the height of the tallest sibling (also works with Modifier.fillMaxHeight)
@Preview
@Composable
private fun FirmwareListItem(
progressState: Float = 0.8f,
onItemClick: () -> Unit = {}
) {
Surface(
shape = RoundedCornerShape(12.dp),
) {
Column(modifier = Modifier.fillMaxWidth()) {
Row(
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.fillMaxWidth().height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.SpaceBetween
) {
Column(modifier = Modifier.weight(0.6f)
) {
Text(
modifier = Modifier.padding(start = 4.dp),
text = "Name",
fontSize = 8.sp,
style = MaterialTheme.typography.caption
)
Spacer(modifier = Modifier.height(2.dp))
Text(
text = "File name",
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.overline
)
Spacer(modifier = Modifier.height(12.dp))
Text(
modifier = Modifier.padding(start = 4.dp),
text = "Version for processor type on platform",
fontSize = 8.sp,
style = MaterialTheme.typography.caption
)
Spacer(modifier = Modifier.height(2.dp))
Text(
text = "Version information",
style = MaterialTheme.typography.subtitle1
)
Spacer(modifier = Modifier.height(8.dp))
Text(
modifier = Modifier.padding(start = 4.dp),
text = "Comment",
fontSize = 8.sp,
style = MaterialTheme.typography.caption
)
Spacer(modifier = Modifier.height(2.dp))
Text(
text = "asdkfj lakdsjf laskjd flaksdjf lk jalskdfj alksdj falskjdf lk alskdj falksdj flkasdj flaksdj flkasjd flkasjd flkasjd flkasdj",
style = MaterialTheme.typography.body2
)
}
Column(
Modifier.weight(0.4f),
horizontalAlignment = Alignment.End
) {
Text(
text = "Creation date",
textAlign = TextAlign.End,
style = MaterialTheme.typography.caption
)
Spacer(modifier = Modifier.height(8.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = Icons.Default.Face,
modifier = Modifier.size(12.dp),
contentDescription = null,
)
Spacer(modifier = Modifier.width(4.dp))
Text(text = "In Progress")
}
Spacer(Modifier.weight(1f))
Button(onClick = { /*TODO*/ }) {
Text(text = "Upgrade")
}
}
}
LinearProgressIndicator(modifier = Modifier.fillMaxWidth(), progress = progressState)
}
}
}
Chris Sinco [G]
04/14/2022, 11:56 AMLilly
04/14/2022, 12:25 PMChris Sinco [G]
04/14/2022, 1:44 PMLilly
04/14/2022, 1:52 PM