-
19 Oct 2011 4:24 PM #1
Answered: How can I get these three buttons to centered and evenly spaced within the container?
Answered: How can I get these three buttons to centered and evenly spaced within the container?
Just wondering if anyone can let me know how I can get these three buttons to centered and evenly spaced within the container?
Code:Ext.define('rpc.view.home.indexView', { extend: 'Ext.Panel', alias: 'widget.homeView', config: { items: [{ xtype: 'container', layout: { type: 'vbox', pack: 'center' }, defaults: { xtype: 'button', margin: '10 10 0 10' }, items: [{ text: 'Videos', cls: 'x-button-quicknav' }, { text: 'Events', cls: 'x-button-quicknav' }, { text: 'Sites', cls: 'x-button-quicknav' }] }] }, initialize: function () { console.log('rpc.view.home.index ~ initialize'); } });
-
Best Answer Posted by rockinthesixstring
You're right, this works equally well
Code:xtype: 'container', layout: { type: 'hbox', pack: 'center' }, defaults: { xtype: 'button', ui: 'plain', flex: 1, cls: 'x-button-rpc' }, items: [{ text: 'Videos' }, { text: 'Events' }, { text: 'Sites' }]
-
19 Oct 2011 9:34 PM #2
We use a toolbar with spacers for our button bar which works out great, f.e.:
Hope this helps.Code:{ xtype: 'toolbar', ui: 'light', style: 'background: #444', defaults: { iconMask: true, iconAlign: 'center', pack: 'justify', badgeCls: 'x-badge badge-left', style: 'font-size: .8em', ui: 'plain' }, items: [ { xtype: 'spacer' }, { iconCls: 'video' }, { xtype: 'spacer' }, { iconCls: 'photo1' }, { xtype: 'spacer' }, { iconCls: 'locate4' }, { xtype: 'spacer' }, { iconCls: 'chat3' }, { xtype: 'spacer' }, { iconCls: 'nodes2' }, { xtype: 'spacer' } ] }
-
20 Oct 2011 8:02 AM #3
This got me most of the way there. I really didn't want to use a "toolbar" simply because of the theming... but I just cheated and set it to a non-useful theme "none"
Code:Ext.define('rpc.view.home.indexView', { extend: 'Ext.Panel', alias: 'widget.home-indexView', config: { items: [{ xtype: 'toolbar', ui: 'none', defaults: { iconAlign: 'center', iconMask: true, pack: 'justify', ui: 'plain', style: 'border: 1px solid #c4c4c4; background-color: White;', flex: 1 }, items: [{ text: 'Videos' }, { text: 'Events' }, { text: 'Sites' }] }] }, initialize: function () { console.log('rpc.view.home.index ~ initialize'); } });
-
20 Oct 2011 8:26 AM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,653
- Vote Rating
- 14
- Answers
- 17
You can just use a container with an hbox layout and pack center.
Code:config: { layout: { type: 'hbox', pack: 'center' } }
-
20 Oct 2011 9:14 AM #5
You're right, this works equally well
Code:xtype: 'container', layout: { type: 'hbox', pack: 'center' }, defaults: { xtype: 'button', ui: 'plain', flex: 1, cls: 'x-button-rpc' }, items: [{ text: 'Videos' }, { text: 'Events' }, { text: 'Sites' }]


Reply With Quote