Home > Back-end >  How can i click on component behind any component in jetpack compose?
How can i click on component behind any component in jetpack compose?

Time:06-28

Let say i have a two surface in a box and they are on top of each other;

Box(
                    modifier = Modifier.fillMaxSize(),
                    contentAlignment = Alignment.Center
                ) {
                    Surface(
                        modifier = Modifier.size(200.dp).clickable{},
                        color =  Color.Red
                    ) {}
                    Surface(
                        modifier = Modifier.size(50.dp),
                        color = Color.Blue
                    ){}
                }

View:

enter image description here

When I click on the blue surface, I want the red surface to be clicked.

Or I want to make the blue surface "Click Invisible"

How can i achieve this?

CodePudding user response:

If you want red one to have ripple effect when you touch blue Composable you can use a shared InteractionSource to trigger interaction for different composables

//            
  • Related