2016-10-25 82 views
1

,使用此佈局:Nativescript摺疊網格佈局行仍然發生在UI

<GridLayout columns="70, *" rows="auto, auto, auto"> 

    <Label row="0" col="0" rowSpan="3" text="A" style="background-color: red;"></Label> 

    <Label row="0" col="1" text="B" style="background-color: green;"></Label> 
    <Label row="1" col="1" text="C" visibility="collapse" style="background-color: blue;"></Label> 
    <Label row="2" col="1" text="D" style="background-color: orange"></Label> 

</GridLayout> 

是否有一個原因,我可以看到排B和d之間的空白?我預期的行d上去,走行的地方C.

我是一個物理設備上測試所以這裏的結果的快速漆: enter image description here

我期待的結果這樣的表現HTML表格:

<table> 
    <tbody> 
     <tr> 
      <td rowspan="3" style="width: 70px; background-color: red;">A</td> 
      <td style="width: 500px; background-color: green;">B</td> 
     </tr> 

     <tr> 
      <td style="display: none; background-color: blue;">C</td> 
     </tr> 

     <tr> 
      <td style="background-color: orange;">D</td> 
     </tr> 
    </tbody> 
</table> 

這裏的HTML結果的剪斷: enter image description here

回答

2

那是因爲你已經定義了一個GridLayout的3行和您的標籤d設置成第三行。即使標籤C被摺疊,它的位置也不會被佔用。

如果您想到底有沒有一個佈局第二張圖片,那麼我的建議是:

<GridLayout columns="70, *" rows="auto"> 
    <Label row="0" col="0" text="A" style="background-color: red;"></Label> 
    <StackLayout row="0" col="1"> 
     <Label text="B" style="background-color: green;"></Label> 
     <Label text="C" visibility="collapse" style="background-color: blue;"></Label> 
     <Label text="D" style="background-color: orange"></Label> 
    </StackLayout> 
</GridLayout> 

P/S:如果你把標籤C返回可見,佈局將調整本身也

+0

有道理......我忘了,因爲它是在GridLayout本身中定義的,所以無論如何它都會堅持3行。我會按照你的建議去做一個StackLayout,謝謝! – Odubuc

+0

不客氣,快樂編碼 –