I'm trying to hide the system bars in a compose ap...
# compose
d
I'm trying to hide the system bars in a compose app, and it works well until I need show a popup. When the popup is shown, it shows the system bar. If
PopupProperties(dismissOnBackPress = false)
is passed then it shows the bar briefly. Sample in 🧵
Copy code
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        WindowInsetsControllerCompat(window, window.decorView).apply {
            hide(WindowInsetsCompat.Type.systemBars())
            systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
        }

        setContent {
            ExampleAppTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Column(modifier = Modifier.fillMaxSize()) {
                        DropDown("Android")
                    }
                }
            }
        }
    }
}

@Composable
fun DropDown(name: String, modifier: Modifier = Modifier) {
    Box {
        var isMenuExpanded by remember { mutableStateOf(false) }
        Button(onClick = { isMenuExpanded = true }) {
            Text(text = "Show DropDown")
        }
        DropdownMenu(
            expanded = isMenuExpanded,
            onDismissRequest = { isMenuExpanded = false },
            properties = PopupProperties(dismissOnBackPress = false)
        ) {
            DropdownMenuItem(text = { Text(text = "DropDownItem") }, onClick = { /*TODO*/ })
        }
    }
}
dropdownbug.mp4
x
Try putting that
var isMenuExpanded by remember { mutableStateOf(false) }
outside the
Box { }
scope
d
Thanks! I tried it, and it didn't change the behavior unfortunately.
😥 1
198 Views