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

Luka

07/27/2021, 8:13 AM
Hi. Can you help me to remove start padding from buttons text
@Composable
fun RepeatButtonsRow( onConfirmClicked: () -> Unit, onRemoveClicked: () -> Unit, onEditClicked: () -> Unit, showEditButton: Boolean ) { Row(horizontalArrangement = Arrangement.Start) { Button( onClick = { onConfirmClicked.invoke() }, elevation = ButtonDefaults.elevation(defaultElevation = 0.dp), colors = ButtonDefaults.textButtonColors(backgroundColor = Color.Transparent) ) { Text( text = stringResource(id = R.string.confirm), textAlign = TextAlign.Left, color = colorResource(id = R.color.red_clickable_link) ) } Button( modifier = Modifier.padding(start = 16.dp), onClick = { onRemoveClicked.invoke() }, elevation = ButtonDefaults.elevation(defaultElevation = 0.dp), colors = ButtonDefaults.textButtonColors(backgroundColor = Color.Transparent) ) { Text( text = stringResource(id = R.string.split_remove), color = colorResource(id = R.color.red_clickable_link) ) } if (showEditButton) { Button( modifier = Modifier.padding(start = 16.dp), onClick = { onEditClicked.invoke() }, elevation = ButtonDefaults.elevation(defaultElevation = 0.dp), colors = ButtonDefaults.textButtonColors(backgroundColor = Color.Transparent) ) { Text( text = stringResource(id = R.string.edit), color = colorResource(id = R.color.red_clickable_link) ) } } } }
i

iamthevoid

07/27/2021, 8:14 AM
contentPadding
argument in button
1
l

Luka

07/27/2021, 8:15 AM
What i see is this:
contentPadding helps but still some space at start:
t

Tin Tran

07/27/2021, 8:38 AM
You can
Box
with
Modifier.clickable {}
instead
l

Luka

07/27/2021, 9:16 AM
By having Text wrapped in a Box instead of a Button i think i will lose btn states (pressed, …)?
t

Tin Tran

07/27/2021, 11:14 AM
I don’t see any state in your code. What do you mean by button states
z

Zach Klippenstein (he/him) [MOD]

07/27/2021, 1:18 PM
clickable
takes a
MutableInteractionSource
which gives you access to those states.
👍 2
Also, source code is easier to read in slack if you use the code block formatting or put it in a snippet.
l

Luka

07/28/2021, 6:13 AM
Thanks @Zach Klippenstein (he/him) [MOD]. Will use block formatting next time. @Tin Tran I meant pressed, focused (selector), like you have in xml based world (different look for different state) :)