2012-07-26 76 views
1

有一個表單面板,它就像一個容器。然後我有另一個表單面板,我在那裏添加一個文本框和一個按鈕。我需要這個表單面板在屏幕的中心。和文本框的按鈕底部(我應該可以將它放在窗體的任何位置,如Absolute佈局)。在屏幕中居中表單面板

我的代碼如下;並且它不按我想要的方式工作。可有一個人看這個

Ext.define('MyApp.view.MyView', { 
    extend: 'Ext.form.Panel', 
    alias: 'widget.myview', 
    frame: true, 
    height: 800, 
    hidden: false, 
    hideMode: 'visibility', 
    id: 'myviewid', 
    autoScroll: false, 
    bodyPadding: 5, 

    initComponent: function() { 
     var me = this; 

     Ext.applyIf(me, { 
      items: [{ 
       xtype: 'form', 
       height: 330, 
       width: 400, 
       layout: { 
        type: 'absolute' 
       }, 
       bodyPadding: 10, 
       title: 'Care Fusion User Login', 
       anchor: '250 250', 
       items: [{ 
        xtype: 'textfield', 
        id: 'name', 
        width: 233, 
        name: 'name', 
        fieldLabel: 'Nmae', 
        growMax: 200, 
        x: 10, 
        y: 30 
       } { 
        xtype: 'button', 
        height: 30, 
        width: 256, 
        text: 'Click', 
        x: 240, 
        y: 110 
       }] 
      }] 
     }); 

     me.callParent(arguments); 
    } 

}); 

回答

3

嘗試在外部容器使用以下佈局:

layout: { 
    align: 'middle', 
    pack: 'center', 
    type: 'hbox' 
}, 

那麼你內在的表格將被放置在這個外形的中心。

+0

你的意思是用你的代碼替換'type:'absolute''行? – Illep 2012-07-26 18:36:55

+0

不,我認爲這應該包括到您的第一個表單視圖.MyView – sha 2012-07-26 18:47:40