Search code examples
buttonandroid-jetpack-composefloatingscaffold

How to make Scaffold floatingActionButton not clickable through


I have Scaffold and floatingActionButton on it. floatingActionButton has layout as Row with fillMaxWidth and buttons on it.

Under floatingActionButton I have some buttons and I could click on empty floatingActionButton Rows place, and I could click through floatingActionButton and click on buttons which are located on the main view, under floatingActionButton.

How to make Row layout not clickable through?

Scaffold(modifier = Modifier.fillMaxWidth(),
floatingActionButton = {
  Box(modifier = Modifier.padding(start = 32.dp)) {
    Row(
            modifier = Modifier
                .border(
                    width = 1.dp,
                    color = Color(0xFFC1C1C1),
                    shape = RoundedCornerShape(size = 12.dp)
                )
                .fillMaxWidth()
                .height(80.dp)
                .background(
                    color = Color(LocalAppCustomResources.current.attachmentBackGround),
                    shape = RoundedCornerShape(size = 12.dp)
                )
                .padding(16.dp)
    }
  }
)

Solution

  • You can try to use a Surface instead of the Box like this:

    Surface(
        modifier = Modifier
            .wrapContentSize()
            .padding(start = 32.dp)
    ) {
        Row(
            //...
        ) {
            //...
        }
    }