Search code examples
androidandroid-jetpack-composematerial-designfloating-action-buttonmaterial-components-android

Do I really need to set icon size manually when using LargeFloatingActionButton in Jetpack Compose?


I assumed that when using LargeFloatingActionButton, the icon size would be somehow set automatically (this is the point of using LargeFloatingActionButton, so that everything works out of box, right?).

But by default, the icon size is small, like in a regular FAB.

enter image description here

Scaffold(
        ...
        floatingActionButton = {
            LargeFloatingActionButton(onClick = { /*TODO*/ }) {
                Icon(Icons.Filled.Add, null)
            }
        }
    ) { contentPadding ->
        // Screen content
        ...
    }

And this is my LargeFloatingActionButton with fixed icon size (36dp taken from official FAB specification):

enter image description here

            LargeFloatingActionButton(onClick = { /*TODO*/ }) {
                Icon(Icons.Filled.Add, null,
                    modifier = Modifier.size(36.dp))
            }

Am I missing something? Or do I really, as a developer, need to manually check the official Material Design 3 specification and set everything manually, when implementing every component, because there is no official complete solution yet?


Solution

  • As a Android developer who have just graduated several months ago and dive into real world program writing, I need to say that, M3(Material Design 3) is just a design pattern advised by some Google workers, which is just a small samll part of the design world. 99% of the company don't use this design pattern(Every Android app project always have 1 or 2 or more designer whose job is to design the color and the size of the components in app and etc and give the design paper to you).

    Dont care about this detail. If you think 36dp is beautiful, then just use it. If you think the default size is not pretty, then specify your value.

    Finally you dont need to use it anyway in your job. Just take it easy in your learning road.