2013-07-01 53 views
2

如何才能在XML中製作網格佈局。比如說我想要一個4x4的電路板。我將不得不做16個按鈕,並格式化他們使用jss?例如這就是我所擁有的,但還不是電路板格式。鈦,網格佈局

<Alloy> 
    <Window layout="relative" backgroundColor="white"> 

     <Button class="button left-buttons">square</Button> 
     <Button class="button left-buttons" top="40">square</Button> 
     <Button class="button left-buttons" top="80">square</Button> 

     <Label id="User" left="100" top="120" text=">(NULL)<"></Label> 

     <Button class="button right-buttons" >square</Button> 
     <Button class="button right-buttons" top="40">square/square</Button> 
     <Button class="button right-buttons" top="80">square</Button> 

     <Button class="Games" top="200">square</Button> 
     <Button class="Games" top="280">square</Button> 
     <Button top="360">square</Button> 

    </Window> 
</Alloy> 
+0

另外,我無法找到關於鈦的XML格式的任何文檔,如果您碰巧知道某個鏈接可以指向正確的方向,請謝謝。 – Mikecit22

+0

你是什麼意思的XML格式? –

回答

5

只需使用水平佈局,並將容器視圖設置爲屏幕大小即可。水平佈局將按行排列子視圖。你可能需要做一點數學才能正確使用,或者只是使用百分比寬度。

這裏是一個無樣式的2×2板得到一個簡單的例子,你開始:

<Alloy> 
    <Window layout="horizontal" horizontalWrap="true" backgroundColor="white"> 
     <Button width="50%" height="50%" title="TopLeft"/> 
     <Button width="50%" height="50%" title="TopRight"/> 
     <Button width="50%" height="50%" title="BottomLeft"/> 
     <Button width="50%" height="50%" title="BottomRight"/> 
    </Window> 
</Alloy> 

至於「XML格式」你的意思是this guide on Alloy's XML Markup?

+0

至於文件是的,但有更深入的文件。在XML中完成一個窗口的整個佈局並使用JS只是爲了窗口的功能,這是更好的辦法,因爲這是我目前正在接近這個項目?並感謝您的幫助:-) – Mikecit22

+0

該文檔與我發現的一樣深入,不要害怕嘗試!我通常將視圖佈局留給.xml,對.tss文件進行樣式設置,其他所有內容都放在控制器中。 –

0

有一對夫婦,你可以使用小部件。

gridWidget
一種鈦合金,插件爲網格,使用的tableview。

buttonGrid
Appcelerators自己創建的按鈕與一些動畫效果的網格鈦合金部件。 合理定製。 Titanium APIv3文檔包含使用和教程。