4

下面是我的代码。它在 iPhone 上完美运行,但图像在 Android 上被拉伸,所以它没有显示标签。

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);

请帮助我。我是钛新手

4

2 回答 2

1

尝试在 Android 中设置所有对象(按钮/标签)属性,例如:

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

希望这可以帮助。

于 2011-09-08T07:07:52.153 回答
0

尝试创建第一个视图,然后添加到视图按钮,然后添加到视图图像视图中,这样您将实现您想要的。

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);
于 2013-11-13T14:54:11.697 回答