如何在 .Net MAUI 中设置初始条目宽度?

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

How to set initial entry width in .Net MAUI?

问题

如何在 .Net MAUI 中设置初始的输入控件宽度?

英文:

I am developing an app which I would like to set an Entry control with an initial size on the width. Currently, despite I can write in the Entry control, this one is too small for a convenient UI.

So how to set initial entry control width in .Net MAUI?

答案1

得分: 2

使用在你的 XAML 文件中的 Entry 类的 MinimumWidthRequest 属性。
例如:

<Entry x:Name="mainEntry"
       Placeholder="在这里输入文本..."
       ClearButtonVisibility="WhileEditing"
       MaxLength="255"
       MinimumWidthRequest="500"/>
英文:

Use the MinimumWidthRequest property of the Entry class in your xaml file.
For example:

<Entry x:Name="mainEntry"
       Placeholder="Write your input text here..."
       ClearButtonVisibility="WhileEditing"
       MaxLength="255"
       MinimumWidthRequest="500"/>

答案2

得分: 1

我发现自己更经常使用网格和百分比,而不是手动设置尺寸。这使设计能够很好地响应不同的设备。

另外,一个好的技巧是在填充时使用边距。如果我不知道想要多宽的东西,我设置左右边距,它会居中,看起来在各种屏幕上都很好。

英文:

I find myself using grids and percentages more often than manually setting sizes. It makes the design respond well to different devices.

Also, good trick is to use margins, when you fill. If I do not know how wide I want something, I set left and right margins, it gets centered, and looks good on variety of screens.

huangapple
  • 本文由 发表于 2023年3月12日 13:17:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75711188.html
匿名

发表评论

匿名网友

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

确定