Reputation: 1107
I want to set a background image in sencha to a panel:
EDIT
Ext.define('components.NewPanel', {
extend: 'Ext.Panel',
style: {
background:'#ffffff',
backgroundImage: 'url(icon.PNG)',
backgroundSize: '10% 85%',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'bottom left',
},
initialize: function () {
var newIcon=Ext.create('Ext.Img', {
src: "image1.png",
cls: "img",
scope: this,
listeners: {
tap: {
fn :function (img, evt) {
Ext.Msg.alert("This is a test");
},// function
}// tap
}//listeners
});//create
this.add([newIcon]);
},
config: {
layout: {
type: 'fit'
}
}
});
But nothing is displayed. What to do? any help is appreciated.
Upvotes: 2
Views: 17402
Reputation: 406
Use bodyStyle
config
Ext.create('Ext.panel.Panel', {
border: false,
bodyStyle: {
'background': 'url(wall.jpg) !important'
}
//another config
....
})
Upvotes: 1
Reputation: 41
I had to set the background of the panel body to transparent, because otherwise that white background prevented my image from showing. Try adding this:
bodyStyle: 'background: transparent;',
Upvotes: 1
Reputation: 1388
Try this @b.i and here we go!,
var panel = new Ext.Panel({
id:'pnl1',
fullscreen:true,
style: {
background:'#ffffff',
backgroundImage: 'url(path/image/your_image.PNG)',
backgroundSize: '100% 100%',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'bottom left',
},
html: '<img class="logo" src="path/image/another_image_yours.jpg"/>',
layout: {
type:'card',
},
items:[]
})
Create this panel and after can you use it. Try create single and view your image first.
backgroundSize: x y
is size of your image and backgroundPosition: x y
is position of your image.
I hope help you. :) Ciao
Upvotes: 0
Reputation: 768
You can do as bellow
Ext.define('MyApp.view.WelcomePanel', {
extend: 'Ext.form.Panel',
alias: 'widget.WelcomePanel',
config: {
style:"background-color:white;",
itemId:'WelcomePanel',
fullscreen:true,
layout: 'card',
html:'<div align="center" style="background-color:white;" ><img src="http://src.sencha.io/http://yoursite.com/splash.png" ></div>',
items: [
{xtype:'MainPanel', docked:'top'},
]
}
});
Upvotes: 1