4

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

stealthyninja
  • 10,343
  • 11
  • 51
  • 59
spaleja
  • 1,435
  • 15
  • 24

2 Answers2

1

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.

Muhammad Zeeshan
  • 8,722
  • 10
  • 45
  • 55
0

try to create first view, then add into view button and then add into view image view, by this you will achieve what you want.

var buttonview = Ti.UI.createView();
buttonview.width = '50pt';
buttonview.height = '50pt';

var button = Ti.UI.createButton();
button.width = Ti.UI.FILL;
button.height = Ti.UI.FILL;
button.title = 'Activity';
button.verticalAlign = Ti.UI.TEXT_VERTICAL_ALIGNMENT_BOTTOM;
button.font = 
{
   fontSize: '5pt',
   fontWeight : 'bold',
};

buttonview.add(button);

var imageview = Ti.UI.createImageView();
imageview.image = '/activities.png';
imageview.height = '80%';
imageview.width = '80%';
imageview.top = '1pt';
buttonview.add(imageview);
Martin
  • 1
  • 1