Sencha touch 如何在sencha touch中对齐按钮中心的图标?

Sencha touch 如何在sencha touch中对齐按钮中心的图标?,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我是新来的森查触摸。我有一个带有合成图标的按钮。图标根据按钮的给定大小显示在“我的按钮”的右下角。有人能帮我调一下吗?iconAlign属性不适用于我 { xtype: 'button', ui: 'action', iconMask: true,

我是新来的森查触摸。我有一个带有合成图标的按钮。图标根据按钮的给定大小显示在“我的按钮”的右下角。有人能帮我调一下吗?iconAlign属性不适用于我

                        {
                            xtype: 'button',
                            ui: 'action',
                            iconMask: true,
                            iconCls: 'compose',
                            iconAlign:'center',
                            width:35,
                            height: 25,
                            action:'landedInfo'
                        }

您必须将padding属性设置为0,因为您提供的宽度和高度太小,因此与您为“iconAlign”提供的“center”值冲突:

{
    xtype: 'button',
    ui: 'action',
    iconMask: true,
    iconCls: 'compose',
    iconAlign:'center',
    width:35,
    height: 25,
    padding:0,
    action:'landedInfo'
}
一种方法是将宽度和高度增加到100x50,然后在不接触padding属性的情况下得到一个居中图标。。。 我承认一开始可能很难发现这一点


希望这有助于

在css中设置边距帮助我将图标放在中间:

.x-tab .x-button-icon.compose,.x-button .x-button-icon.x-icon-mask.compose
{

margin-left:-5px;
margin-top:-5px;
margin-right:-7px;
margin-bottom:-5px;
    }

我尝试了这个,为我工作:

{
    xtype: 'button',
    ui: 'normal',
    text:'LOGOUT',
    iconMask: true,
    iconCls: 'user',
    iconAlign:'center',            
     padding:0,
    cls: 'x-iconalign-top',

}

如果你使用图标字体,你可以用css

.x-button-icon {
    /*Icon centering*/
    position:absolute;
    width:1em;//set width of icon relative(icon is font)
    top:50%;
    margin-top:-0.5em;//half of icon height shift back
    left:50%;
    margin-left:-0.5em;//half of icon width shift back
}

我不想增加按钮的大小。嗯,我可以用css实现它。谢谢你,波克你不必,你只需将“padding”设置为0,你将有一个居中的图标,而不改变大小。改变按钮大小只是为了解释。你不应该需要css。。。