Xamarin 在XAML中对齐要内联的两个标签

Xamarin 在XAML中对齐要内联的两个标签,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我正在用Xamarin的形式做造型。我对对齐垂直2标签其他尺寸有问题: 这是我的XAML代码: <StackLayout HorizontalOptions="EndAndExpand" Grid.Row="0" Grid.Column="1"> <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand"> <Label Text="03" FontSize

我正在用Xamarin的形式做造型。我对对齐垂直2标签其他尺寸有问题:

这是我的XAML代码:

<StackLayout HorizontalOptions="EndAndExpand" Grid.Row="0" Grid.Column="1">
    <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
        <Label Text="03" FontSize="42" FontAttributes="Bold" Style="{StaticResource LabelNormal}" HorizontalTextAlignment="End" VerticalTextAlignment="End" />
        <Label Text="\20" Style="{StaticResource LabelNormal}" HorizontalTextAlignment="End" VerticalTextAlignment="End" />
    </StackLayout>
    <Label Text="Chưa xử lý" Style="{StaticResource LabelNormal}" HorizontalTextAlignment="End" />
</StackLayout>

我希望“30”和“/20”在底部是直的。我怎么能做到


已解决

这是我的简单解决方案。我加了一个边距底部是“-7”,效果很好

<Label Text="03" FontSize="42" FontAttributes="Bold" Style="{StaticResource LabelNormal}" HorizontalTextAlignment="End" VerticalTextAlignment="End" Margin="0,0,0,-7" />


<>代码> 当您的解决方案工作时,它可能不是最好的,请考虑下一个主题:

  • 填充中的负值会在不同的屏幕和平台上引入不一致的副作用。这应该被认为是一个非常肮脏的黑客行为,应该避免
  • 表演。您似乎过度使用了
    StackLayout
    。尝试
    Grid
    ,它将减少要渲染的UI元素的数量并增加加载时间

祝你好运

现在我有了比这个话题更好的解决方案:没错。我想我过度使用了
stacklayout
。我的布局很难在Xamarin表单上进行设计。我试图避免大型控制。不过,谢谢你的回复和推荐,这对我很有帮助。我将删除项目中的一些
stacklayout