0

I want to try to enlarge the icon inside the box to be filling the parent width, which normally can be approached with fillMaxWidth, but the Icon didn't react, only the boundary/the imaginary boundary of the icon enlarged to the parent width.

original: before fillmaxwidth

after: after fillmaxwidth

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

1 Answers1

0

Without specifing a size modifier in the Icon there is a default size of 24.dp

Internal Icon code:

private fun Modifier.defaultSizeFor(painter: Painter) =
    this.then(
        if (painter.intrinsicSize == Size.Unspecified || painter.intrinsicSize.isInfinite()) {
            DefaultIconSizeModifier //24.dp
        } else {
            Modifier
        }
    )

Use something like:

Icon(Icons.Filled.Delete, "", Modifier.size(32.dp))

With and without size modifier:

enter image description here

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