2017-10-17 64 views
0

努力獲得正確的佈局按圖片 正如你的情況下看到你卡尼似乎與columnspan和行跨度奮鬥佈局問題,電網無法得到它的權利

enter image description here

下面是我做了什麼

<Grid 
      ColumnSpacing="10" 
      RowSpacing="10" 
      HorizontalOptions="FillAndExpand" 
      VerticalOptions="FillAndExpand"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="Auto"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto"/> 
       <ColumnDefinition Width="Auto"/> 
       <ColumnDefinition Width="50"/> 
       <ColumnDefinition Width="Auto"/> 
       <ColumnDefinition Width="Auto"/> 
      </Grid.ColumnDefinitions> 


      <Label Grid.Row="0" Grid.ColumnSpan="4" Text="Title" BackgroundColor="Beige" HorizontalOptions="FillAndExpand"/> 
      <Label Grid.Row="1" Grid.Column="3" Text="Label1" HorizontalOptions="Start"/>   
      <Label Grid.Row="1" Grid.Column="4" Text="Label2"/> 
      <Label Grid.Row="2" Grid.Column="1" Text="Label3" HorizontalOptions="Start"/> 
      <Label Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="4" Text="Label4" BackgroundColor="Gainsboro"/> 
     </Grid> 

任何想法,更正

回答

0

你已經在過去的兩個標籤出錯了。列應爲0,像

Grid.Column = 「0」

試試這個:

<Grid 
    ColumnSpacing="10" 
    RowSpacing="10" 
    HorizontalOptions="FillAndExpand" 
    VerticalOptions="FillAndExpand"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="50"/> 
     <ColumnDefinition Width="*"/> 
     <ColumnDefinition Width="Auto"/> 
    </Grid.ColumnDefinitions> 

    <Label Grid.Row="0" Grid.ColumnSpan="5" Text="Title" BackgroundColor="Gray" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/> 
    <Label Grid.Row="1" Grid.Column="3" Text="Label1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>   
    <Label Grid.Row="1" Grid.Column="4" Text="Label2" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/> 
    <Label Grid.Row="2" Grid.Column="0" Text="Label3" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/> 
    <Label Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Text="Label4" BackgroundColor="Silver" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" LineBreakMode="WordWrap"/> 
</Grid> 
+0

感謝您reply.Nearly有可能使標籤2文本適合例如「長長標籤」。標籤上的HeightRequest4。請問fillandexpand無法填充所有內容? – developer9969

+0

我已經更新了我的答案,最後一列的定義就像並更新了label4 –

+0

謝謝! – developer9969