Views and labels
Hi All
Im trying to simply layout a window and I have fallen at the first hurdle.
I have a business Name with a telephone number underneath which is coming from a database.
The business Name could go over two lines and I want to maintain the top and bottom padding and the distance from the Name and the telephone number.
The code below formats nicely but goes pear shape when the text goes over two lines. I thought of putting the telephone number in a view and that would move down as the text gets longer. still did not work. Out of ideas now.
var header = Ti.UI.createView({
backgroundColor:'#fff',
top:0,
height:'auto',
width:320,
});
var businessName = Ti.UI.createLabel({
text: result.fieldByName('Name'),
color:'#333',
font:{fontSize:18,fontWeight:'Normal', fontFamily:'Arial'},
left:16,
height:'auto',
top:0,
bottom: 16
});
var Telephone = Ti.UI.createLabel({
text: 'Telephone: '+result.fieldByName('Telephone'),
color:'#333',
font:{fontSize:12, fontWeight:'Normal', fontFamily:'Arial'},
left:16,
top: 40,
height: 14,
bottom: 16,
});
header.add(businessName);
header.add(Telephone);
win.add(header);
Many thanks
1 Answer
-
Accepted Answer
Set the buisinessName label to a blob:
buisinessName.toBlob();
Now you have access to the width and height parameters. nex thing to do is set your Telephone labels height to:
top: (buisinessName.y + buisinessName.height) + spacing,