android - 如何在 Row 上添加 TextField?
问题描述
我无法在行上添加文本字段。我已经尝试过使用 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...
我想这样输出;
用户名:(文本字段)
解决方案
试试下面的代码
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 })
}
}
}
}
输出:
推荐阅读
- postgresql - 使用 copy 或 pgcopy 批量插入时间戳 int Postgres
- xquery - 如何限制 Marklogic 中特定集合搜索的 Search API?
- image - 通过 API 从 Instagram 帐户获取照片
- python - 无法找出在脚本中使用代理轮换来加速执行过程的正确方法
- javascript - 如何在 Reactjs 中使用搜索栏过滤表格行
- firebase - Firebase 实时数据库验证编号增量
- javascript - 使用 Jest 的 React.js 自定义钩子测试
- aop - Maven 测试用例不调用 AspectJ 方面
- android - 为什么我们需要 ViewModelProvider.Factory 将视图模型传递给屏幕?
- python - 尝试使用动态文本和确认按钮编写 tkinter 弹出窗口