Search code examples
androidfloating-action-buttonandroid-jetpack-compose

Jetpack UI Compose. How to create FloatingActionButton?


I want to create a FloatingActionButton placed at the bottom right in the activity using jetpack compose.
Can anyone help me with an example for the above scenario?


Solution

  • You can create FloatingActionButton try below @Compose function use your drawable icon.

    @Composable
    fun MyFloatingActionButton() {
          val icon = +imageResource(R.drawable.ic_add_icon)
                FloatingActionButton(icon = icon, color = Color.Red, elevation = 8.dp)
    }