0

我无法在行上添加文本字段。我已经尝试过使用 row、flexrow、flowrow、stack、wrap 和 container。在列上它有效。

java.lang.IllegalArgumentException: minWidth 2147483647.ipx should be finite
at androidx.ui.core.Constraints.<init>(Constraints.kt:48)   
at androidx.ui.core.Constraints$Companion.tightConstraintsForWidth(Constraints.kt:72) 
at...

我想这样输出;

用户名:(文本字段)

4

1 回答 1

5

试试下面的代码

MaterialTheme {
                val state = +state { " " }
                Padding(left = 16.dp, right = 16.dp) {
                    FlexRow(
                        crossAxisAlignment = CrossAxisAlignment.Center
                    ) {
                        inflexible {
                            Container() {
                                Text{
                                    Span(
                                        text = "Username: ",
                                        style = TextStyle(
                                            color = Color(0xFFFF0000),
                                            fontSize = 18.sp,
                                            fontWeight = FontWeight.W200,
                                            fontStyle = FontStyle.Normal
                                        )
                                    )
                                }
                            }
                        }
                        expanded(1f) {
                            TextField(value = state.value, onValueChange = { state.value = it })
                        }
                    }
                }
            }

输出:

在此处输入图像描述

于 2019-11-13T07:47:09.397 回答