我正在移植一个 Xamarin 应用程序,其中包含 StackLayout 内的标签,不幸的是,文本不完整,并且看起来丢失的文本位于屏幕之外。
如何多行显示标签文本?
<StackLayout Orientation="Vertical" HorizontalOptions="Start">
<Label Text="Pain and Stress Relief"
FontSize="16"
TextColor="Black"
FontAttributes="Bold"
VerticalOptions="Start"
HorizontalOptions="Start" />
<Label Text="Users seeking relief from physical pain, inflammation, anxiety, or stress."
FontSize="16"
TextColor="Black"
VerticalOptions="Start"
HorizontalOptions="Start" />
</StackLayout>
我找到的解决方案是使用 Grid 而不是使用 StackLayout
<Grid HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="Pain and Stress Relief"
x:Name="label_title_01"
FontSize="16"
TextColor="Black"
FontAttributes="Bold"
VerticalOptions="Start"
HorizontalOptions="Start" />
<Label Grid.Row="1" Text="Users seeking relief from physical pain, inflammation, anxiety, or stress."
x:Name="label01"
FontSize="16"
TextColor="Black"
VerticalOptions="Start"
HorizontalOptions="Start" />
</Grid>