Textfield在Jetpack Compose中占用了额外的空间。

huangapple go评论72阅读模式
英文:

Textfield takes extra space in Jetpack Compose

问题

When I am trying to put another composable next to TextField, TextField takes extra place.
Textfield在Jetpack Compose中占用了额外的空间。

红色是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.Textfield在Jetpack Compose中占用了额外的空间。

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

huangapple
  • 本文由 发表于 2023年6月15日 14:12:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76479582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定