[AC-2205] Labels with a height of "Ti.UI.SIZE" have a form of 'padding' on the top and bottom
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-02-09T05:58:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | alignment, label |
Reporter | Paul Hamilton |
Assignee | Ritu Agrawal |
Created | 2014-01-30T16:23:14.000+0000 |
Updated | 2016-03-08T07:41:12.000+0000 |
Description
While trying to top align a label with an image, i noticed that the label was pushed down a bit, rather then being flush with the top of the image. The labels create extra spacing for their text, even when set to Ti.UI.SIZE. I am sure this is a regression as i have found past examples where this was not the case.
alloy:
XML
<Alloy>
<Window class="container">
<View>
<ImageView class="image"></ImageView>
<Label></Label>
</View>
</Window>
</Alloy>
TSS
"Label": {
top: 0,
text: "Label is bigger then the text",
backgroundColor: "red",
height: Ti.UI.SIZE,
width: Ti.UI.SIZE,
verticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP,
color: "#000000",
font: {
fontFamily: "HelveticaNeue-Light",
fontSize: 18
}
}
"ImageView": {
top: 0,
height: 64,
width: 64,
image: "/appicon.png"
}
"View": {
layout: "horizontal",
height: Ti.UI.SIZE,
width: Ti.UI.SIZE,
}
Please provide a complete and runnable test case that demonstrates this issue. You mentioned the label does not align with the image but your code snippet does not refer to an image.
While not strictly needed to see the effect, i did add in an image to help see it visually. The label itself meets the image, but the text inside the label is pushed down. In this link from 2 years ago, This is the effect i would be looking for / expecting. The text inside the label to be at the VERY top/bottom of the label height. https://developer.appcelerator.com/question/124694/align-text-to-top-of-label. Notice the orange text fills the whole space.
Setting height to Ti.UI.SIZE sets the label height to fit the text. It is not really center aligned in this case. I changed the height to a large value (100) and that displayed a large label with a top aligned text but it had the same gap from the top as with Ti.UI.SIZE. I don't see any difference in terms of gap or alignment with Ti.UI.SIZE or an absolute value.
Correct, i tried the same thing. The verticalAlign property was added after the fact to attempt make it even "more" top. This is still undesired behavior i assume.
Based on your above comments, this should be classified as a bug and assigned?
I checked with the engineering and it is expected behavior. Titanium SDK is following text handling rules as per iOS guidelines. You will notice that there is no gap on the top if you use a character with ascent in your sample code (for example, È) https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/Introduction/Introduction.html