Composable disappears after clicking on button, if there is a SurfaceView in the background

938 views Asked by At
setContent {
    AndroidView(modifier = Modifier) {
        SurfaceView(it).apply {
            holder.addCallback(this@MainActivity)
        }
    }
    Column {
        Button(onClick = {}) {
            Text(text = "Button")
        }
        ...
    }
}

This is basically the setup I have in the onCreate function of the activity. Starting the activity works normal, but as soon as the button is clicked, the Column composable is not visible anymore (whether it is not being drawn or hidden behind the SurfaceView, I have no idea..).

Adding zIndex modifiers to both the AndroidView as well as the Column wasn't helping. Also the problem (or maybe even a bug in Jetpack Compose?) is only observable with a SurfaceView inside the AndroidView, other Views seem to be working.

1

There are 1 answers

0
Niklas On BEST ANSWER

If anyone stumbles over this question:

This is a known bug in the current Jetpack Compose build (1.0.0-beta08) which is supposed to be fixed with the next version.

As a workaround I was able to do it the other way round, creating the SurfaceView as well as a ComposableView in XML and adding my content to the ComposableView.