标签之间的距离是否正确

问题描述 投票:0回答:1

你能告诉我如何在XAML - Xamarin.Forms中设置两个标签之间的距离。在此标签之前,我的所有边距= 0。标签之间的距离对我来说很长。我尝试了几个案例并且我喜欢设置保证金小于0(<0),但我认为这不是最好的。我的代码部分:

 <Label Text="{Binding ObjecA.X}" FontSize="Micro" FontAttributes="None" Margin="0,0,0,-5"/>
 <Label Text="{Binding ObjectB.X}" FontSize="Medium" FontAttributes="Bold"  TextColor="Navy" Margin="0,-5,0,-2"/>

你能告诉我更好的解决方案吗?谢谢

c# xaml xamarin
1个回答
0
投票

我想知道你的Label是否有机会在StackLayout

如果是这样,你可以在Spacing本身设置StackLayout属性。默认情况下是6。

<StackLayout Spacing="0">
     <Label Text="{Binding ObjecA.X}" FontSize="Micro" FontAttributes="None" Margin="0"/>
     <Label Text="{Binding ObjectB.X}" FontSize="Medium" FontAttributes="Bold"  TextColor="Navy" Margin="0"/>
     ...
</StackLayout>

然后再也不需要玩负面的Margin了。

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.