Search code examples
sencha-touch-2sencha-architect

Button touches border of toolbar


When I dock a button to right in the toolbar, it starts touching the upper border of the toolbar like this:

enter image description here

Here is my code:

Ext.define('MyApp.view.MyFormPanel', {
    extend: 'Ext.form.Panel',

    config: {
        items: [
            {
                xtype: 'textfield',
                label: 'Field'
            },
            {
                xtype: 'textfield',
                label: 'Field'
            },
            {
                xtype: 'toolbar',
                docked: 'bottom',
                items: [
                    {
                        xtype: 'button',
                        ui: 'back',
                        text: 'Back'
                    },
                    {
                        xtype: 'button',
                        docked: 'right',
                        ui: 'forward',
                        text: 'Continue'
                    }
                ]
            }
        ]
    }

});

Solution

  • I used to have the same problem, but I solved it! You use, just like I did, xtype: 'toolbar' to dock your buttons. What you have to use is

    xtype: 'titlebar'

    Now, if you have some buttons in your titlebar, just set the align property, like this:

     xtype: 'titlebar',
     items: [
          {
             xtype: 'button',
             ui: 'back',
             text: 'Back',
             align: 'left'
          },
          {
             xtype: 'button',
             ui: 'forward',
             text: 'Continue',
             align: 'right'
          }
     ]
    

    Check Sencha Docs for more info: Ext.TitleBar