2
@Composable
fun Sample(){
    val startPadding = 10.dp
    Column {
        Text(
            text = "sample text",
            modifier = Modifier
                .paddingFromBaseline(top = 30.dp)
                .padding(start = startPadding)
        )
        Text(
            text = "sample text",
            modifier = Modifier.padding(start = startPadding)
        )
    }
}

The above Composable contains two Text elements arranged vertically in a Column. Both Text elements have the same value set for their start padding. The preview is below

code preview 1

something weird happens when the paddingFromBaseline is set after padding i.e

@Composable
fun Sample(){
    val startPadding = 10.dp
    Column {
        Text(
            text = "sample text",
            modifier = Modifier
                .padding(start = startPadding)
                .paddingFromBaseline(top = 30.dp)
        )
        Text(
            text = "sample text",
            modifier = Modifier.padding(start = startPadding)
        )
    }
}

code preview 2

The padding before the first Text seems to have doubled, is this a bug or a feature?

I'm under the impression that the order in which Modifier methods are called doesn't matter so the extra padding shouldn't be there.

Kun.tito
  • 165
  • 1
  • 7

0 Answers0