减小Android中Entry的外部空间。

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

Reduce outer space for Entry in Android

问题

我在一个.NET MAUI应用程序中使用了一个包含3个不同行的网格。行高度已经设置好。

当查看行高度时,我无法将其减小,因为它已经变得太小了(可以在顶部的选择颜色上看到)。

但是,我可以看到输入框下方和顶部(我会说是外部)的空间可以减小。

在iOS上,这并不那么困扰,但在Android上目前确实有问题。

我该如何做呢?

减小Android中Entry的外部空间。

英文:

I use a Grid with 3 different Rows in a .NET MAUI App. The RowHeight is already set.

When looking at the RowHeight, I can't reduce the size as is getting already too small then (as can be seen at the selection color on the top).

But, what I can see is that the space below the line of an Entry and at the top (I would say outer) could be reduced.

On iOS it does not bother that much, but in Android currently yes.

How can I do this?

减小Android中Entry的外部空间。

答案1

得分: 1

你应该更改边距设置。您可以将其设置为1-5左右,这样它就会更窄。

边距="2"
英文:

You should change margin settings. You can set it around 1-5 and it will be thinner.

Margin="2"

答案2

得分: 1

以下是您要翻译的内容:

这是对Mert Altiparmak答案的补充。

您可以使用Margin属性通过将其设置为负数来减小外部空间,例如Margin="-2"。如果值为正数,它将增加外部空间。

此外,Margin可以传递四个参数,如Margin="left, top, right, bottom"。您可以将其中之一设置为负数以减少一侧的空间。

而您说:

> 在iOS上并不会太影响,但在Android上目前是的。

所以您可以使用XAML中的平台差异 ,例如:

<Entry.Margin>
    <OnPlatform x:TypeArguments="Thickness" Default="0">
        <On Platform="Android" Value="-2,-2,-2,-2" />
    </OnPlatform>
</Entry.Margin>

==== 附加内容 ====

也许还可以使用这样的样式吗?

<Style TargetType="Entry">
    ...
    <Setter Property="Margin" Value="{OnPlatform 0, iOS='0, 0, 0, 0', Android='0, -2, 0, -2'}" />
</Style>
英文:

Here is a suppleme to Mert Altiparmak's answer.

You can use the Margin property to reduce the outer space by setting it as a negative. Such as Margin=&quot;-2&quot;. If the value is positive number, it will increase the outer space.

In addition, the Margin can be passed four parameters such as Margin = &quot;left, top, right, bottom&quot;. You can set one of then as a negative to reduce one side space.

And you said

> On iOS it does not bother that much, but in Android currently yes.

So you can use Platform differences in the xaml such as:

    &lt;Entry.Margin&gt;
        &lt;OnPlatform x:TypeArguments=&quot;Thickness&quot; Default=&quot;0&quot;&gt;
            &lt;On Platform=&quot;Android&quot; Value=&quot;-2,-2,-2,-2&quot; /&gt;
        &lt;/OnPlatform&gt;
    &lt;/Entry.Margin&gt;

==== Additional ====

Maybe also possible with this a Style like this?

&lt;Style TargetType=&quot;Entry&quot;&gt;
    ...
	&lt;Setter Property=&quot;Margin&quot; Value=&quot;{OnPlatform 0, iOS=&#39;0, 0, 0, 0&#39;, Android=&#39;0, -2, 0, -2&#39;}&quot; /&gt;
&lt;/Style&gt;

huangapple
  • 本文由 发表于 2023年7月11日 14:06:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76659096.html
匿名

发表评论

匿名网友

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

确定