英文:
Textfield takes extra space in Jetpack Compose
问题
When I am trying to put another composable next to TextField, TextField takes extra place.
红色是TextField。
橙色是应该紧挨着它的可组合部分。
我尝试在Modifier
上使用.widthIn(1.dp, Dp.Infinity)
。
另外我注意到TextField有这个:
modifier = modifier
.defaultMinSize(
minWidth = TextFieldDefaults.MinWidth,
minHeight = TextFieldDefaults.MinHeight
)
在其Modifier
上,
val MinWidth = 280.dp
英文:
When I am trying to put another composable next to TextField, TextField takes extra place.
Red is TextField.
Orange is the composable that should be next to it exactly.
I tried to use .widthIn(1.dp, Dp.Infinity)
on Modifier
Also I noticed that TextField has this
modifier = modifier
.defaultMinSize(
minWidth = TextFieldDefaults.MinWidth,
minHeight = TextFieldDefaults.MinHeight
)
on its Modifier
,
val MinWidth = 280.dp
答案1
得分: 1
So, basically I used BasicTextField and added .width(IntrinsicSize.Min)
in its Modifier
.
英文:
So, basically I used BasicTextField and added .width(IntrinsicSize.Min)
in its Modifier
答案2
得分: 1
请使用BasicTextField
而不是TextField
。
TextField
具有一些不可自定义的属性。
英文:
Use BasicTextField
instead of TextField
.
TextField
has some non-customizable properties
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论