你能告诉我如何在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"/>
你能告诉我更好的解决方案吗?谢谢
我想知道你的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
了。
希望这可以帮助!