自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Sencha Touch快速入門2.0之Box布局

移動開發(fā)
Sencha Touch快速入門2.0之Box布局是本文要介紹的內(nèi)容,Sencha touch里的布局應(yīng)該理解為:該控件內(nèi)部子項的排列方式。

Sencha Touch快速入門2.0之Box布局是本文要介紹的內(nèi)容,上一篇講到Sencha Touch快速入門2.0之Chorme瀏覽器調(diào)試功能介紹,接著在學(xué)習(xí)布局的內(nèi)容。

Sencha Touch里的布局有五種

hbox

vbox

card

fit

auto[默認]

實際上可以分為Box布局和Fit布局兩種。

Sencha touch里的布局應(yīng)該理解為:該控件內(nèi)部子項的排列方式。

我們今天先來看看box布局

Box布局

顧名思義,box布局就是一個個的box組成的。

hbox: 水平排列、垂直居中、靠左置頂

vbox: 豎直堆疊、水平居中、靠上置頂

hbox:

  1. hbox   
  2. Ext.setup({      
  3.   tabletStartupScreen: 'tablet_startup.png',      
  4.   phoneStartupScreen: 'phone_startup.png',      
  5.   icon: 'icon.png',      
  6.   glossOnIcon: false,      
  7.   onReady : function() {          
  8.     var pnl = new Ext.Panel({              
  9.     fullscreen: true,              
  10.     layout: 'hbox',              
  11.   items:[                  
  12.      {xtype:'button',text:'按鈕1'},                  
  13.      {xtype:'button',text:'按鈕2'},                  
  14.      {xtype:'button',text:'按鈕3'}             
  15.      ]         
  16.    });      
  17. }});  
  18.    
  19. vbox: 

Sencha Touch快速入門2.0之Box布局

將以上的hbox改為vbox

Sencha Touch快速入門2.0之Box布局

但是,只是知道這些,還不足以玩轉(zhuǎn)box布局,下面讓我們看看其他常見的box布局實例。

vbox變型:

  1. vbox變型   
  2. Ext.setup({      
  3. tabletStartupScreen: 'tablet_startup.png',      
  4. phoneStartupScreen: 'phone_startup.png',      
  5. icon: 'icon.png',      
  6. glossOnIcon: false,      
  7. onReady : function() {          
  8. var pnl = new Ext.Panel({              
  9. fullscreen: true,              
  10. layout: 'vbox',              
  11. defaults: {                  
  12. flex: 1              
  13. },              
  14.   items:[                  
  15.   {xtype:'button',text:'按鈕1'},                  
  16.   {xtype:'button',text:'按鈕2'},                  
  17.   {xtype:'button',text:'按鈕3'}             
  18.   ]          
  19.  });      
  20. }}); 

Sencha Touch快速入門2.0之Box布局

關(guān)于這里的flex,sencha Touch使用了css3中的彈性和模型,所以大家如果有興趣可以看看 擴展閱讀:css3中的彈性盒模型

vbox變型2:

在上面代碼的defaults中加入width : '100%',得到下圖

Sencha Touch快速入門2.0之Box布局

了解以上內(nèi)容之后,我們來想想經(jīng)典的九宮格布局如何實現(xiàn)吧!

相必大家也已經(jīng)心中有數(shù)了。

經(jīng)典的九宮格布局:

九宮格

  1. Ext.setup({      
  2. tabletStartupScreen: 'tablet_startup.png',    p  
  3. honeStartupScreen: 'phone_startup.png',      
  4. icon: 'icon.png',      
  5. glossOnIcon: false,      
  6. onReady : function() {          
  7. var pnl = new Ext.Panel({              
  8. fullscreen: true,             
  9.  layout: 'vbox',              
  10.  defaults: {                  
  11.  flex: 1,                  
  12.  width: '100%',                  
  13.  defaults: {                      
  14.  flex: 1,                     
  15.   height: '100%'    
  16.   }                  
  17.  },              
  18.  items:[{                 
  19.        xtype: 'panel',    
  20.        layout: 'hbox',    
  21.  items:[                      
  22.     {xtype:'button',text:'按鈕1'},    
  23.     {xtype:'button',text:'按鈕2'},   
  24.     {xtype:'button',text:'按鈕3'}     
  25.   ]              
  26.  },{                 
  27.  xtype: 'panel',       
  28.  layout: 'hbox',     
  29. items:[                      
  30.    {xtype:'button',text:'按鈕4'},    
  31.    {xtype:'button',text:'按鈕5'},  
  32.    {xtype:'button',text:'按鈕6'}]    
  33.  },{                  
  34.  xtype: 'panel',  
  35.  layout: 'hbox',   
  36.  items:[    
  37.  {xtype:'button',text:'按鈕7'},    
  38.  {xtype:'button',text:'按鈕8'},   
  39.  {xtype:'button',text:'按鈕9'}   
  40. ]             
  41. }]          
  42. });     
  43. }}); 

Sencha Touch快速入門2.0之Box布局

嫌緊挨著不舒服?別急,我們還有些屬性沒用上!你沒有猜錯那就是-----margin、padding!你知道怎么做的!

松散九宮格:

松散九宮格

  1. Ext.setup({     
  2.   tabletStartupScreen: 'tablet_startup.png',      
  3.   phoneStartupScreen: 'phone_startup.png',      
  4.   icon: 'icon.png',      
  5.   glossOnIcon: false,      
  6.   onReady : function() {          
  7.     var pnl = new Ext.Panel({     
  8.     fullscreen: true,    
  9.     layout: 'vbox',   
  10.     defaults: {     
  11.   flex: 1,      
  12.   width: '100%',    
  13.    padding: 10,   
  14.    defaults: {    
  15.     flex: 1,     
  16.     height: '100%',   
  17.     margin: 10                  
  18.   }                  
  19. },              
  20.  items:[{         
  21.           xtype: 'panel',   
  22.           layout: 'hbox',   
  23.  items:[           
  24.             {xtype:'button',text:'按鈕1'},   
  25.             {xtype:'button',text:'按鈕2'},   
  26.             {xtype:'button',text:'按鈕3'}          
  27.       ]            
  28.    },{                 
  29.     xtype: 'panel',   
  30.     layout: 'hbox',    
  31.     items:[            
  32.               {xtype:'button',text:'按鈕4'},    
  33.               {xtype:'button',text:'按鈕5'},      
  34.               {xtype:'button',text:'按鈕6'}       
  35.           ]             
  36.     },{                  
  37.      xtype: 'panel',                  
  38.      layout: 'hbox',       
  39.   items:[                      
  40.      {xtype:'button',text:'按鈕7'},     
  41.      {xtype:'button',text:'按鈕8'},      
  42.      {xtype:'button',text:'按鈕9'}     
  43.    ]              
  44.  }]          
  45. });      
  46. }}); 

Sencha Touch快速入門2.0之Box布局

OK,到這里,你已經(jīng)可以對box已經(jīng)可以運用自如了,下一篇,我們將接著講解sencha touch里的另一種布局“Fit”布局。

小結(jié):Sencha Touch快速入門2.0之Box布局的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 博客園
相關(guān)推薦

2011-09-02 15:58:38

Sencha Touc布局

2011-09-02 15:18:49

Sencha Touc

2011-09-02 16:08:09

Sencha ToucAPI文檔

2011-09-02 15:28:10

Sencha Touc瀏覽器

2011-10-26 10:12:53

Sencha Touc布局

2011-10-26 10:21:40

Sencha Touc組件

2011-09-30 14:15:10

Sencha ToucSencha Touc

2012-01-10 13:21:33

Sencha Touc使用data包

2011-10-26 10:43:19

Sencha Touc

2011-09-02 15:12:29

PhoneGapSencha Touc

2011-10-26 10:32:05

Sencha Touc數(shù)據(jù)視圖

2011-10-18 09:49:40

新特征Sencha Touc

2011-07-26 09:41:50

Sencha Touc特性HTML 5

2010-11-22 10:31:17

Sencha touc

2011-07-25 15:55:21

Sencha ToucHtml 5

2011-11-16 13:14:02

Sencha TouciOS本地應(yīng)用

2011-09-05 10:20:21

Sencha ToucAPP

2011-07-25 16:21:22

Sencha touc

2011-07-26 09:46:53

Sencha Touc

2011-09-02 16:21:08

Sencha Touc自動生成工具
點贊
收藏

51CTO技術(shù)棧公眾號