2014-10-02 46 views
0

我正在嘗試爲鈦合金應用程序實現佈局。這是到目前爲止我的代碼:查看容器中斷我的代碼

<Alloy>

<Window class="container">` 
     <View id="containerView" class="container" layout="vertical"> 
     <View id="navBarView" layout='horizontal'> 
       <Button id="id" onClick="doClick" title="title" width="50%"height="50dp"/> 
       <Button id="id1" onClick="doClick" title="title" width="50%" height="50"/> 
      </View>  
     <!-- Here are several labels which should be grouped vertically --> 
     </View> 
</Window> </Alloy> 

如果我刪除containerView顯示的標籤,但垂直居中(很抱歉的壞格式) 。我希望它們在navBarView之後直接顯示。當我按原樣運行代碼時,它根本不顯示任何標籤。我的navBarView一直工作在例外狀態。

我很感謝每一個投入,我對鈦是新的。

回答

1

只是把width & heigth & top爲爲例您的TSS文件:

"#navBarView":{ 
     height:'20%', 
     top:0, 
     width:'100%' 
} 
".yourlabelContainer":{ 
    height:'80%', 
    layout:'vertical', 
    width:'100%' 
} 
".mylabel":{ 
    font:{ 
     fontSize:19, 
     fontWeight:'bold' 
    }, 
    color:'#000' 
    height:'20%' //(100/5) 
} 

和XML文件:

<Alloy> 
    <Window class="container">` 
     <View id="containerView" class="container" layout="vertical"> 
     <View id="navBarView" layout='horizontal'> 
      <Button id="id" onClick="doClick" title="title" width="50%"height="50dp"/> 
      <Button id="id1" onClick="doClick" title="title" width="50%" height="50"/> 
     </View> 
     <View calss="yourlabelContainer"> 
      <Label class="mylabel>Lab1</Label> 
      <Label class="mylabel>Lab2</Label> 
      <Label class="mylabel>Lab3</Label> 
      <Label class="mylabel>Lab4</Label> 
      <Label class="mylabel>Lab5</Label> 
     </View> 
     </View> 
    </Window> 
</Alloy> 
+0

謝謝,上面的屬性並獲得成功。 – 2014-10-06 08:31:40