Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-12577

[android] horizontal layout doesnt compute correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 3.0.0, Release 3.1.0
    • Fix Version/s: Release 3.2.0
    • Component/s: Android
    • Environment:

      titanium 3.1.0 master
      android 4.0.3
      device / simulator

      Description

      When using a horizontal layout with a view where the width is Ti.UI.FILL, you expect that view to take as much width as possible without expanding outside its parent.
      Running the example below, you can see that it works correctly on ios (click the label for info)
      On android, the label will actually have the width of its parent, and not the expected width

      i did not test but i assume the problem is the same with vertical layout

      var win = Titanium.UI.createWindow();
      win.backgroundColor = '#ccc';
       
      var container = Ti.UI.createView({
          	height:70,
          	layout:'horizontal',
              horizontalWrap:false,
          	backgroundColor:'red'
         	})
      var view = Ti.UI.createView({
          	width:100,
          	backgroundColor:'blue'
         	})
      container.add(view);
       
      var view2 = Ti.UI.createLabel({
      	width:Ti.UI.FILL,
      	backgroundColor:'green',
      	textAlign:'right',
      	text:'TEST'
      })
      container.add(view2);
       
      view2.addEventListener('click', function(e) {
      	alert('my width is ' + e.source.rect.width + ' when it should be ' + eval(container.rect.width - view.rect.width));
      })
      win.add(container);
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              sunila Sunila
              Reporter:
              farfromrefuge Martin Guillon (Inactive)
              Reviewer:
              Allen Yeung
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-15538
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code