Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2205] Labels with a height of "Ti.UI.SIZE" have a form of 'padding' on the top and bottom

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-02-09T05:58:07.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsalignment, label
ReporterPaul Hamilton
AssigneeRitu Agrawal
Created2014-01-30T16:23:14.000+0000
Updated2016-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,
}

Comments

  1. Ritu Agrawal 2014-01-31

    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.
  2. Paul Hamilton 2014-01-31

    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.
  3. Ritu Agrawal 2014-02-03

    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.
  4. Paul Hamilton 2014-02-03

    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.
  5. Paul Hamilton 2014-02-07

    Based on your above comments, this should be classified as a bug and assigned?
  6. Ritu Agrawal 2014-02-09

    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

JSON Source