Layout 使用居中按钮创建2x2按钮网格?

Layout 使用居中按钮创建2x2按钮网格?,layout,extjs,sencha-touch-2,Layout,Extjs,Sencha Touch 2,我有一个2x2的按钮网格。现在我想把按钮缩小到 200x200,将每个放置在容器中作为空间放置架,然后居中放置 每个按钮在其各自的容器中 在我看来,我只是 缩小顶部的两个按钮,以便可以看到页面上的间距。 我怎样才能从第一个图像转到第二个图像,这是 Photoshop'ed 目标:(实际上,所有4个居中按钮都是目标) 文件:app.js Ext.application({ launch: function() { var view = Ext.create('Ext.

我有一个2x2的按钮网格。现在我想把按钮缩小到 200x200,将每个放置在容器中作为空间放置架,然后居中放置 每个按钮在其各自的容器中

在我看来,我只是 缩小顶部的两个按钮,以便可以看到页面上的间距。 我怎样才能从第一个图像转到第二个图像,这是 Photoshop'ed

目标:(实际上,所有4个居中按钮都是目标)

文件:app.js

Ext.application({ launch: function() { var view = Ext.create('Ext.Container', { layout: { type: 'vbox' }, items: [ { xtype: 'container', layout: 'hbox', flex: 1, items:[ { xtype: 'container', layout: 'hbox', flex: 1, items:[ { xtype:'button', text: 'Home', ui: 'plain', style: 'background-color: #c9c9c9', height: 200, width: 200 } ] }, { xtype: 'container', layout: 'hbox', flex: 1, items:[ { xtype:'button', text: 'News', ui: 'plain', style: 'background-color: #b9b9cb', height: 200, width: 200 } ] } ] }, { xtype: 'container', layout: 'hbox', flex: 1, items:[ { xtype:'button', text: 'Mail', ui: 'plain', style: 'background-color: #a9c9c9', flex: 1 }, { xtype:'button', text: 'Search', ui: 'Search', style: 'background-color: #c9c9c9', flex: 1 } ] } ] }); Ext.Viewport.add(view); } }); 外部应用程序({ 启动:函数(){ var view=Ext.create('Ext.Container'{ 布局:{ 类型:“vbox” }, 项目:[ { xtype:'容器', 布局:“hbox”, 弹性:1, 项目:[ { xtype:'容器', 布局:“hbox”, 弹性:1, 项目:[ { xtype:“按钮”, 文本:“主页”, ui:'普通', 样式:“背景色:#c9c9c9”, 身高:200, 宽度:200 } ] }, { xtype:'容器', 布局:“hbox”, 弹性:1, 项目:[ { xtype:“按钮”, 文字:“新闻”, ui:'普通', 样式:“背景色:#b9b9cb”, 身高:200, 宽度:200 } ] } ] }, { xtype:'容器', 布局:“hbox”, 弹性:1, 项目:[ { xtype:“按钮”, 文本:“邮件”, ui:'普通', 样式:“背景色:#a9c9c9”, 弹性:1 }, { xtype:“按钮”, 文本:“搜索”, 用户界面:“搜索”, 样式:“背景色:#c9c9c9”, 弹性:1 } ] } ] }); Ext.Viewport.add(视图); } }); 文件:index.html

<!doctype html> <html manifest="" lang="en-US"> <head> <meta charset="UTF-8"> <title>Sencha</title> <link rel="stylesheet" href="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/resources/css/sencha-touch.css" type="text/css"> <script type="text/javascript" src="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/sencha-touch-all-debug.js"></script> <script type="text/javascript" src="app.js"></script> <body> </body> </html> 森查
只需将
centered:true
添加到所有按钮的配置中即可

祝你好运

p/S:该配置实际上将组件设置为其父组件的中心(水平和垂直)