Search code examples
titaniumtitanium-mobiletitanium-alloy

Ti.UI.Labels Overlap while using label.left=previous_lablel.right in Titanium


I'm new bee to Titanium,

I want to set the UILabel.left based on the previous UILabel.right and I'm using index.js to execute this functionality

Here is the code:

$.password_label.right=$.login_button.center;// This works fine
$.register_label.left=$.password_label.right;// Issue in this line
$.index.open();

Image in which it overlaps, though my aim is to make it side by side.enter image description here

Thanks in advance


Solution

  • First of all in Titanium framework, Button.center is a point (Object : {x,y}) ...

    you should use layout : horizontal to achieve this :

    //In your xml file :
    <View class='labeslcontainer'>
      <Label id="labelPassword"/>
      <Label id="labelRegister"/>
    </View>
    

    and the in your tss file :

    ".labeslcontainer":{
       layout:horizontal
     }
    "#labelPassword":{
       text:'your text |',
    }
    "#labelRegister":{
       text: 'your text',
       left : 7
    }
    

    and so on. Using left in horizontal container will position your labels side by side.