我想使用sencha touch创建自定义工具栏。使用Ext.Toolbar,我可以创建一个像样的屏幕标题栏。但我的要求是将我公司的品牌形象标识放在标题栏的中心,而不是下面代码提供的简单文本。
{
xtype : 'toolbar',
docked: 'top',
title: 'My Toolbar'
}
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:8)
试试这个
{
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'
}
]
}
答案 1 :(得分:1)
您可以使用title属性在工具栏中添加图像。以下是我的一个应用程序中的一些修改过的代码。此外,通过定义自定义类,您可以分配自定义xtype并重用主工具栏......无论哪种方式,代码都应该包含您要查找的内容:
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();
}
});