Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Adding a label with top:0 shows up in center of a view

var lblPatientName = new Label(
        {
            text:'Patient Name:',
            left:5,
            top:10
        }
    );

This is the result…

The black line is the top of /that/ view…

stupid alignment problem

— asked November 27th 2010 by Critter
  • label
  • layout
0 Comments

3 Answers

  • Hi Critter

    I don't recognise the code new Label; the Titanium API method for creating a new label is Ti.UI.createLabel().

    Bear in mind that the Titanium.UI.Label top property will position a view relative to its immediate parent. Try setting a background on your label's parent temporarily to have a better idea of how the label and its parent relate to each other.

    I'm afraid I would need to see the complete code to understand better what is going on.

    Hope this of some help anyway

    — answered November 27th 2010 by Paul Dowsett
    permalink
    0 Comments
  • ah. sorry wasn't even paying attention to that.. I am using that redux script..

    but even if I create the label using the longhand method.. it still positions improperly..

    The view (parent of the label) has the background color of gray that you see in the picture…

    var studyList = new TableView({
            top:0, left:0, right:0,height:'70%', backgroundColor:'silver'
        });
        var bottomList = new View({
            top:'70%',left:0,height:'30%', backgroundColor:'gray'
        })
    
        var barIndex = 0;
        var btnSettings = new Button({
           title: 'Settings'
        });
        var mBar = new TabbedBar({
            labels:['Unfiltered', 'Unread', 'My Studies',,,,,'Previous 20','Next 20'],
            backgroundColor:'#336699',
            top:10,
            style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
            height:25,
            index:barIndex,
            width:'99%'
        });
        var lineSep = new Label(
        {
            height:3,
            width:'100%',
            borderColor:'black',
            borderWidth:3,
            top:0
        });
        var lblPatientName = new Label(
            {
                text:'Patient Name:',
                left:5,
                top:10
            }
        );
            bottomList.add(lblPatientName);
        //bottomList.add(sep);
        //bottomList.add(btnNext);
        bottomList.add(mBar);
        bottomList.add(lineSep);
    
    — answered November 27th 2010 by Critter
    permalink
    0 Comments
  • bah. I just saw it… the label's height is not set.. so it's at 100%

    — answered November 27th 2010 by Critter
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.