How can I place an image and label on button in Titanium?

spaleja picture spaleja · Sep 8, 2011 · Viewed 7.9k times · Source

Below is my code for the same. It's working perfectly for iPhone but images are stretched for Android so its not showing label.

var friendsButton = Titanium.UI.createButton({
    top : 0,
    left : 91,
    width : 90,
    height : 101,
    style : 0,
    backgroundImage : '/img/buttonMiddle.png',
    image : '/img/friendcopy.png'
});
var friendLabel = Titanium.UI.createLabel({
    top : 35,
    left : 25,
    width : 100,
    height : 100,
    text : 'Friend',
    color : 'white',
    font : {fontSize:12}
});
friendsButton.add(friendLabel);

Please help me in this. I am new to Titanium

Answer

Muhammad Zeeshan picture Muhammad Zeeshan · Sep 8, 2011

Try to set all object (butttons/labels) properties in Android like:

var friendLabel = Titanium.UI.createLabel({
    top : '35dp',
    left : '25dp',
    width : '100dp',
    height : '100dp',
    text : 'Friend',
    color : 'white',
    font : {fontSize:'12dp'}
});

Hope this helps.