Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

customizing sencha touch toolbar

I want to create a custom toolbar using sencha touch. Using Ext.Toolbar, i am able to create a decent screen titlebar. But my requirement is to place my company brand image logo in the center of the title bar not the simple text as provided by the code below.

{
   xtype : 'toolbar',
   docked: 'top',
   title: 'My Toolbar'
}

can anyone help me how to do this ?

like image 922
Nilanchala Panigrahy Avatar asked Mar 26 '26 15:03

Nilanchala Panigrahy


2 Answers

Try this

{
    xtype: 'toolbar',
    docked: 'top',
    layout: {
        type: 'vbox',
        align: 'center',
        pack: 'center'
    },
    items: [
        {
            xtype: 'image',
            width:218,
            height:44,
            src:'http://cdn.sstatic.net/careers/gethired/img/careers2-ad-header-so-crop.png'
        }
    ]
}
like image 196
blessanm86 Avatar answered Apr 02 '26 22:04

blessanm86


You can add the image in your toolbar by using the title attribute. Here is some modified code from one of my apps doing just this. Also, by defining a custom class you can assign a custom xtype and reuse the main toolbar... Either way the code should have what you are looking for:

Ext.define('myApp.view.Maintoolbar', {
    extend: 'Ext.Toolbar',
    xtype: 'maintoolbar',
    requires: [
        //any necessary requirements
    ],
    config: {
        docked: 'top',
        title: '<div style="text-align:center;"><img src="images/logoSmall.png" width="185" height="36" alt="Company Name"></div>',
        padding: '5 5 5 5',
        items: [{
            iconCls: 'arrow_down',
            iconMask: true,
            ui: 'normal',
            //left: true,
            text: 'Menu',
            action: 'openmenu'
        },{
            xtype: 'spacer'
        },{
            xtype: 'button',
            iconCls: 'arrow_down',
            iconMask: true,
            ui: 'normal',
            align: 'right',
            text: 'Logout',
            action: 'logout'
        }]
    },
    initialize: function() {
        this.callParent();
    }
});
like image 29
Jeff Wooden Avatar answered Apr 02 '26 21:04

Jeff Wooden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!