09-27-2012 11:18 PM
I've got two Labels next to each other in a StackLayout with LeftToRight orientation. The first one is a large font, and the second one is a small font. I'd like to have them aligned vertically so that their baselines match. Is there any way to do this?
I was thinking I might need to switch to an AbsoluteLayout, and align them manually. If I do this, is there any way to measure the text so that I don't need to hardcode offsets? Perhaps a way to measure the width of a string with a given font, and get text metrics for a font (ascent/descent, etc)?
09-30-2012 03:00 AM
I'm not sure if its public (RIM, please make it public if its not set so), but I wrote up a related feature request in the JIRA system a while back, which could use some upvoting:
Access to font metrics for UI layout purposes
https://www.blackberry.com/jira/browse/BBTEN-166
In this ticket, I pretty much describe a lot of what you're wanting to do here.
10-01-2012 03:21 AM
Thanks. Looks like it's not public yet, but I'll check back a bit later.
01-31-2013 12:49 PM
01-31-2013 01:31 PM
Setting VerticalAlignment to Bottom for these Labels does not work?
01-31-2013 07:00 PM
Thanks for the reply. The problem with VerticalAlignment Bottom is that larger fonts have more space below the baseline (e.g. for characters like g, q), so the baselines don't line up correctly.
I ended up just using a hardcoded vertical offset. A bit of a hack, and I was trying to avoid this, but it works well enough for now.
01-31-2013 07:05 PM
If the labels have the exact same font size, it does.
Otherwise, no.