Titanium 如何在钛制按钮上放置图像和标签?
下面是我的代码。它在iPhone上运行得很好,但Android的图像被拉伸了,所以它没有显示标签Titanium 如何在钛制按钮上放置图像和标签?,titanium,titanium-mobile,Titanium,Titanium Mobile,下面是我的代码。它在iPhone上运行得很好,但Android的图像被拉伸了,所以它没有显示标签 var friendsButton = Titanium.UI.createButton({ top : 0, left : 91, width : 90, height : 101, style : 0, backgroundImage : '/img/buttonMiddle.png', image : '/img/friendcopy.p
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);
请帮我做这件事。我是Tianium新手尝试在Android中设置所有对象(Buttons/标签)属性,如:
var friendLabel = Titanium.UI.createLabel({
top : '35dp',
left : '25dp',
width : '100dp',
height : '100dp',
text : 'Friend',
color : 'white',
font : {fontSize:'12dp'}
});
希望这有帮助。尝试创建第一个视图,然后添加到视图按钮,然后添加到视图图像视图,这样您将实现您想要的
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);