Marco
08/20/2021, 2:10 PMButton
that contains a Column
(that contains other stuff), but I want that this column fills the remaining space inside the Button
, basically I want that the column fit all the space inside the Button. In the old world I was used to put match_parent
width.
.fillMaxWidth()
doesn't work well because in this way the buttons fills all witdh space in my composable. Any ideas?Stylianos Gakis
08/20/2021, 2:17 PM.weight(1f)
on the column’s modifiers? Is that maybe what you’re looking for?Stylianos Gakis
08/20/2021, 2:18 PM.fillMaxWidth()
I think unfortunatelyMarco
08/20/2021, 2:19 PMJzach
08/20/2021, 2:21 PMMarco
08/20/2021, 2:22 PM@Composable
internal fun InternalGradientButton(
text: String,
modifier: Modifier = Modifier,
textColor: Color,
enabled: Boolean,
gradientBrush: Brush,
icon: Painter? = null,
onClick: () -> Unit = { },
) {
Button(
modifier = modifier
.wrapContentWidth()
.buttonsDefaultShadow(),
enabled = enabled,
shape = ShapesRounded.medium,
elevation = null,
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent),
contentPadding = PaddingValues(),
onClick = onClick,
) {
val alphaModifier = Modifier.alpha(if (enabled) 1f else 0.6f)
Row(
modifier = Modifier
.background(gradientBrush)
.padding(vertical = CWDimen.CommonMargin16, horizontal = CWDimen.CommonMargin16)
.then(alphaModifier),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
Text(
modifier = Modifier.then(alphaModifier),
text = text,
color = textColor,
style = MaterialTheme.typography.button
)
icon?.let {
Image(
painter = it,
modifier = Modifier
.padding(start = CWDimen.CommonMargin8)
.size(24.dp),
contentDescription = null
)
}
}
}
}
Marco
08/20/2021, 2:22 PMMarco
08/20/2021, 2:23 PMJzach
08/20/2021, 2:25 PMMarco
08/20/2021, 2:26 PMMarco
08/20/2021, 2:29 PM2f
and fillMaxWidth in order to use the space 50 50Marco
08/20/2021, 2:30 PMwrap_content
,but with the fillMaxWidth on the Row
inside the Button
broke itMarco
08/20/2021, 2:44 PM