Help with label positioning
Hi,
I'm trying to create a table row that looks something like this: http://img72.imageshack.us/img72/3350/labels.png
I need some help :) All the labels are dynamic and I want to create some way that they always will line up.
I think I should create a view that holds the "wind" label together with the windspeed. What I can't figure out how to place is the "m/s" label. This font is smaller than the speed label so the text has to be two different labels. But if I do this the text is layered on top on eachother.
How would you structure this view?
3 Answers
-
something like this maybe? ( some sort of pseudo code here :) )
view_wind( width:120); label_speed (width:60, left:0, bottom:0, textAling:right,font: {fontSize: 24} ) label_m/s (width:60, right:0,bottom:0, textAlign:left, font: {fontSize: 12})
-
When you do the
win.add(label_speed);
Or however you have it set up, instead of doing the same thing (win.add(label_ms)) have the speed label add it instead, and then set the distance from that.
So it'd be something like…
var win = Titanium.UI.currentWindow; var label_speed = Ti.UI.createLabel({ text:'32', font:{fontSize:24}, width:'auto', height:'auto', left:10, top:10 }); var label_ms = Ti.UI.createLabel({ text:'m/s', font:{fontSize:12}, width:'auto', height:'auto', left:15 }); win.add(label_speed); label_speed.add(label_ms);
You might need to change the width of the label_speed to accomodate the m/s, but that should work for the most part :)
-
Thanks, I will try both the solutions and see if they work.