sencha button 右对齐的问题

你可能试验过

docked:'right'

然后右边上下对不齐


你可能试验过

right:'0%'

top'10%'

很难看


你可能试验过

align:'right'

对不起,button没有这个属性


so。。。答案是

items: [{
    xtype: 'button',
    ui: 'mask',
    iconCls: 'refresh',
    handler: refresh
}, {xtype: 'spacer'}, {
    xtype: 'button',
    ui: 'mask',
    iconCls: 'add',
    handler: refresh
}]

加一个space搞定



Just to explain the reason behind this. In Sencha Touch, toolbars are nothing more than containers with an hbox layout and custom styling. So in order to alter the alignment, the pack and other hbox layout configuration you could do:

Code:
layout: {
    pack: 'justify',
    align: 'center' // align center is the default
}
This also means that you can set the property "flex" on every item inside a toolbar to have them take up the remaining space.

Finally I just wanted to paste the code for the Spacer class to show you what it does.

Code:
Ext.Spacer = Ext.extend(Ext.Component, {
    initComponent : function() {
        if (!this.width) {
            this.flex = 1;
        }

        Ext.Spacer.superclass.initComponent.call(this);
    }
});
As you can see you can give a spacer a fixed width, and if you dont do that it will use a flex of one. This means that if you use the following order of items in your toolbar [button, spacer, button, spacer, button], you will get a button on the left, one in the center and one on the right with the spacers both taking up an equal amount of space.

I hope this answered your question.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值