2014-03-28 35 views
1

我有一個屏幕,我認爲vbox應該是正確的佈局使用。 我想要的是一個屏幕上有3個或4個按鈕的屏幕,它們均勻地分佈在屏幕上。 按鈕周圍應有空間並居中。如何在Sencha Touch的vbox佈局中的按鈕之間設置空間

這裏是我的代碼:

{ 
       title: 'Main Menu', 
       iconCls: 'organize', 
       layout: 'vbox', 
       scrollbale: true, 
       items: [{ 
          xtype: 'titlebar', 
          title: 'Main Menu', 
          docked:'top' 
         }, 
         { 
          xtype: 'button', 
          text: 'Button 1', 
          //cls: 'menu_button', 
          flex: 1, 
          ui: 'round', 
          //align: 'center', 
          style: 'margin: 10px; width: 85%; height:30px !important;', 
          //pack:'center', 
          handler: function() { 
           // navigate to the Quote page 
               } 
         }, 
         { 
          text: 'About', 
          xtype: 'button', 
          ui: 'round', 
          centered: true, 
          //cls: 'menu_button', 
          style: 'margin: 10px; width: 85%; height:30px;', 
          flex: 1, 
          handler: function() { } 
         }, 
         { 
          text: 'FAQ', 
          xtype: 'button', 
          //cls: 'menu_button', 
          style: 'margin: 10px; width: 85%; height:30px !important;', 
          flex: 1, 
          ui: 'round', 
          handler: function() { } 
         }] 

      } 

爲了使我的問題清楚,這裏是截圖 enter image description here

因此,大家可以看到,按鈕是不是均勻的大連我都設置它們的寬度和身高,他們之間沒有空間。

我想要的佈局是這樣的:

enter image description here

請點我到正確的方向。

謝謝你,我的朋友。

+0

你好?任何人都可以請說一下嗎?我問錯誤的問題嗎?爲什麼它甚至沒有得到一個答覆? – Franva

回答

4

是否這樣?

http://jsfiddle.net/woosah/3zdc7/5/

config: { 
     fullscreen: true, 
     scrollable: true, 
     layout: 'vbox', 
     defaults: { 
      flex: 1 
     }, 
     items: [{ 
      xtype: 'titlebar', 
      title: 'Main Menu', 
      docked: 'top' 
     }, { 
      xtype: 'button', 
      text: 'Button 1', 
      ui: 'round', 
      margin: '40px 40px 0 40px' 
     }, { 
      text: 'About', 
      xtype: 'button', 
      ui: 'round', 
      margin: '40px 40px 0 40px' 
     }, { 
      text: 'FAQ', 
      xtype: 'button', 
      ui: 'round', 
      margin: '40px' 
     }] 
} 
+0

優秀。但是,請你解釋你爲什麼工作,我的不是?這對我更重要 – Franva

+1

你的主要問題是中間按鈕上的「居中:真」。 如果你刪除它。並在你的「margin」中添加一個「auto」,如下所示: 「margin:10px auto; to center it;) – user2510728

+0

非常好!謝謝你的解釋。 – Franva

相關問題