0
我嘗試垂直居中包含文本的multiline Label,該文本可以顯示在1行或2行上。Xamarin.Forms:如何在一個行中居中多標籤?
就目前而言,我無法得到預期的渲染...
這是附加的XAML:
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<local:MultiLineLabel
Grid.Row="0"
Grid.Column="1"
BackgroundColor="Orange"
Text="{ Binding encart_titre }"
VerticalTextAlignment="Center"
LineBreakMode="TailTruncation"
Lines="2"
...
/>
這是附加的XAML:
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<local:MultiLineLabel
Grid.Row="0"
Grid.Column="1"
BackgroundColor="Orange"
Text="{ Binding encart_titre }"
VerticalTextAlignment="Center"
LineBreakMode="TailTruncation"
Lines="2"
VerticalOptions="FillAndExpand"
...
/>
你有什麼解釋?我也嘗試添加StackLayound周圍的標籤,但這並沒有改變什麼...
謝謝它與'VerticalOptions =「CenterAndExpand」' –
只要稍微規範:標籤必須嵌入一個'StackLayout' 'VerticalOptions =「CenterAndExpand」'和'HorizontalOptions =「CenterAndExpand」'。 –