我正在尝试使用 Jetpack Compose 将 TextField 和 FAB 放入 BottomBar 内。我用一个盒子包裹了这两个,盒子有修饰符“fillMaxWidth”。
但这两个控件不使用全宽度。
有谁知道如何解决这个问题?
这是我的代码:
@Composable
fun ChatView() {
Scaffold(
topBar= { ChannelButton() },
bottomBar = { ChatBox() },
modifier = Modifier
.padding(10.dp)
) {
ChatList()
}
}
@Composable
fun ChatBox() {
Box(modifier = Modifier
.background(DiscordDarkGray)
.fillMaxWidth()
){
Column(modifier = Modifier
.padding(10.dp)
.fillMaxWidth()) {
HorizontalCenteredRow(modifier = Modifier
.fillMaxWidth()) {
val textState = remember { mutableStateOf(TextFieldValue()) }
TextField(
value = textState.value,
onValueChange = { textState.value = it }
)
Spacer(modifier = Modifier.width(10.dp))
FloatingIconActionButton …Run Code Online (Sandbox Code Playgroud) android kotlin android-studio android-jetpack-compose android-compose-textfield