5

I write this code.

    Image (
        painter = painterResource(id = R.drawable.image),
        contentDescription = "fab",
        modifier = Modifier
            .size(80.dp)
            .clickable(
                interactionSource = remember { MutableInteractionSource() },
                indication = rememberRipple(true),
                onClick = { /* TODO */ }
            )
    )

But, I use Scaffold. So I want to use floating action button or extended floating action button. How can I use floating action button and custom image. I have a circular photo to use for the button.

    Scaffold(
        topBar = {},
        content = {},
        floatingActionButton = {
            Image {
                /* How can I wrire */
            }
        }
    )
vr_min_chan
  • 125
  • 1
  • 9

2 Answers2

8

You can use something like:

Scaffold(
    topBar = {},
    content = {},
    floatingActionButton = {
        FloatingActionButton(onClick = { /*TODO*/ }) {
            Image (
                painter = painterResource(id = R.drawable.xxxx),
                contentDescription = "fab",
                contentScale = ContentScale.FillBounds
            )
        }
    }
)

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0
 FloatingActionButton(
                        backgroundColor = Color(0xFFF7FAFF),
                        onClick = { **TODO** },
                        modifier = Modifier.align(Alignment.BottomEnd).padding(start = 15.dp, top = 15.dp, end = 8.dp, bottom = 15.dp).background(Color.Transparent)) 
                        {
                        Image(painter = painterResource(id = R.drawable.icon_fab_btn), contentDescription = "fab", contentScale = ContentScale.FillBounds,)
                        }

enter image description here

Mirza Adil
  • 352
  • 5
  • 9