1

When placing 2 or more composables in a Box() in jetpack compose, even if they overlap, they can be focused and clicked through each other, is there a way to prevent this behavior?

    Box(
        modifier = Modifier.fillMaxSize()
    ) {
        Column(
            modifier = Modifier
                .fillMaxSize(),
            verticalArrangement = Arrangement.Bottom,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Button(onClick = { /*TODO*/ }) {
                Text(text = "Should NOT be clickable and focusable")
            }
        }
    }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(
                brush = SolidColor(Color.Gray),
                alpha = 0.8f
            ),
        verticalArrangement = Arrangement.Top,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Button(onClick = { /*TODO*/ }) {
            Text(text = "Should be clickable and focusable")
        }
    }

resulting in: enter image description here

Expected behavior is when the button on the top is visible, I don't want the button in the top to be clickable And focusable.

DevineDecrypter
  • 151
  • 1
  • 16

0 Answers0