2013-05-27 92 views
2
var myWin = new Ext.Window({ 
     height : 100, 
     width : 200, 
     maximizable : true, 
     items : [ { 
      xtype : 'button', 
      text : 'myButton' 
     // align : center 
     } ] 

    }); 
    myWin.show(); 

这是我的代码。我想按钮居中,我知道有办法做到这一点,但他们有点长,棘手,是否有一个简单的解决方案,如align : center或类似的东西,应该按钮或文本字段居中?ExtJS中的中心对齐按钮

回答

2

enter image description here

您可以试试这个。这是一种方式(我添加了我的窗口的图片)

Ext.define('MyApp.view.MyWindow', { 
    extend: 'Ext.window.Window', 

    height: 137, 
    width: 233, 
    layout: { 
     align: 'middle', 
     pack: 'center', 
     type: 'hbox' 
    }, 
    title: 'My Window', 

    initComponent: function() { 
     var me = this; 

     Ext.applyIf(me, { 
      items: [ 
       { 
        xtype: 'button', 
        text: 'MyButton' 
       } 
      ] 
     }); 
     me.callParent(arguments); 
    } 
}); 
2

插入buttonAlign: 'center',它应该居中 - 默认为right,我想。见this example