2

I can't figure out where this extra padding comes from. I even added a green background to the Icon to make sure the icon wasn't taking up any space. I read that singleLine can affect inner padding, but setting it to true/false didn't make a difference.

OutlinedTextField(
    modifier = modifier
      .fillMaxWidth()
    value = textFieldValue,
    onValueChange = { newText ->
      textFieldValue = newText
    },
    leadingIcon = if (isCurrency) {
      {
        Icon(
          imageVector = Icons.Filled.AttachMoney,
          contentDescription = null
        )
      }
    } else null,

The screenshot is using the same OutlinedTextField for all fields. The one without the extra padding has the leadingIcon set to null. Any ideas how to remove the padding?

enter image description here

enter image description here

Marty Miller
  • 913
  • 2
  • 11
  • 27

1 Answers1

2

In your case you can use the prefix attribute instead of the leadingIcon:

OutlinedTextField(
    value = text,
    onValueChange = { newText ->
        text = newText
    },
    prefix  =
        {
            Icon(
                imageVector = Icons.Filled.AttachMoney,
                contentDescription = null
            )
        },

)

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841