【发布时间】:2019-05-11 07:36:44
【问题描述】:
<ContentPage.Content>
<StackLayout VerticalOptions="Start" HorizontalOptions="Fill">
<RelativeLayout HeightRequest="100" BackgroundColor="Blue">
<Image x:Name="dishImageView" Aspect="AspectFit" BackgroundColor="Maroon" RelativeLayout.YConstraint="10" RelativeLayout.XConstraint="10" RelativeLayout.WidthConstraint="80" RelativeLayout.HeightConstraint="80" Source="pizza1.png" />
<Label Text="Dominoz Pizza"
x:Name="pizzaTitle"
RelativeLayout.YConstraint="10"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView,
ElementName= dishImageView,
Constant=20,
Property=Width,
Factor=1}"/>
<Label BackgroundColor="Lime" HeightRequest="60" Margin="0,0,20,0" MaxLines="2" LineBreakMode="WordWrap" Text="Dominoz Pixxa is great pizza.. come and eat pizza"
x:Name="pizzaDescription"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView,
ElementName=pizzaTitle,
Constant=10,
Property= Height, Factor=1}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView,
ElementName= dishImageView,
Constant=20,
Property=Width,
Factor=1}"
/>
</RelativeLayout>
</StackLayout>
</ContentPage.Content>
基本上我来自 iOS 背景。在那里,我们使用前导和尾随空格。我在 Xamarin 表单中看不到任何尾随空格选项....你能帮我设置一下吗...这是我正在尝试实现的示例图像。
【问题讨论】:
-
你的意思是
LineBreakMode上Label -
是的,类似的...我想设置描述标签右侧应该始终有 20 个空格。并且标签应该分两行
-
设置
<Label Margin="0,0,20,0" MaxLines="2" LineBreakMode="TailTruncation" ... /> -
我添加了,但它仍然没有出现在两行中
-
你选择
RelativeLayout而不是StackLayouts有什么原因吗?
标签: xamarin.forms