如何使用BottomSheetScaffold(Jetpack compose)的sheetContent在横向模式下填满整个屏幕?

问题描述 投票:0回答:0

我想用底部的支架在横向模式下填充整个屏幕,但它的左右两侧总是有一些剩余空间:Example result

我已经删除了所有可能的填充并在各处使用了

modifier.fillMaxSize
,但空格仍然存在。

这是我使用的非常短的代码:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TESTApplicationTheme {
                MyUI()
            }
        }
    }
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MyUI() {
    val scaffoldState = rememberBottomSheetScaffoldState()
    val coroutineScope = rememberCoroutineScope()

    BottomSheetScaffold(
        modifier = Modifier.fillMaxSize(),
        scaffoldState = scaffoldState,
        sheetContent = {
            Box(modifier = Modifier.fillMaxSize().background(Color.Blue))
        },
        sheetDragHandle = null,
    ) {
        // app UI
        Column(
            modifier = Modifier.fillMaxSize(),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally,
        ) {
            Text(text = "Rest of the app UI")

            Button(
                onClick = {
                    coroutineScope.launch {
                        scaffoldState.bottomSheetState.expand()
                    }
                },
            ) {
                Text(text = "expand")
            }
        }
    }
}
android android-jetpack-compose landscape bottom-sheet android-jetpack-compose-material3
© www.soinside.com 2019 - 2024. All rights reserved.