Daniel Cook
08/04/2023, 2:43 PMPopupProperties(dismissOnBackPress = false)
is passed then it shows the bar briefly. Sample in 🧵Daniel Cook
08/04/2023, 2:44 PMclass 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*/ })
}
}
}
Daniel Cook
08/04/2023, 2:44 PMxoangon
08/05/2023, 8:49 AMvar isMenuExpanded by remember { mutableStateOf(false) }
outside the Box { }
scopeDaniel Cook
08/07/2023, 1:13 PM