Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8147] iOS: Regression: View with 'auto' height is much taller than it should be

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2012-03-21T09:55:21.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterShawn Lipscomb
AssigneeNeeraj Gupta
Created2012-03-20T12:36:45.000+0000
Updated2017-03-24T18:15:15.000+0000

Description

Problem

In the 2.0.0.v20120319003254 continuous-build SDK, a View with a height of "auto" is displayed much taller than it should be. In SDK 1.8.2, the height was correct (only as tall as it needs to be to surround those things it contains). Therefore, this is a regression.

Actual result

With the 2.0.0.v20120319003254 continuous-build SDK, the view (yellow in the testcase below) appears almost the full height of the screen.

Expected result

The view (yellow in the testcase below) should be only tall enough to surround the "X" that is placed into it. This is how it appeared with the 1.8.2 and earlier SDKs.

Testcase

var win1 = Ti.UI.createWindow({  
    backgroundColor:'#fff'
});

var label1 = Ti.UI.createLabel({
  backgroundColor:'green',
	color:'white',
	text:'Spinner should be on top of the X',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	top:40,
	height:40,
	width:'auto'
});
win1.add(label1);

var view1 = Ti.UI.createView({
  backgroundColor:'yellow',
  height:'auto', 
  top:100,
  width:100
});
win1.add(view1);

var spin1=Ti.UI.createActivityIndicator({
                    //right:25,
                    left:25,
                    style:Ti.UI.iPhone.ActivityIndicatorStyle.DARK
                  });
view1.add(spin1);
var marker1=Ti.UI.createLabel({
                    height:'auto',
                    width:'auto',
                    text:'X',
                    //right:25,
                    left:25,
                  });
view1.add(marker1);

win1.open();
spin1.show();

Extra info

This test is working fine in 1.8.2

Comments

  1. Marshall Culpepper 2012-03-21

    The new Composite Layout behavior in 2.0.0 dictates that View "auto" behavior follows FILL (i.e. fill parent container) by default. This will break some apps, but can easily be changed by using the new SIZE constant in place of "auto", i.e:
       Ti.UI.createView({
           width: Ti.UI.SIZE,
           height: Ti.UI.SIZE
       });
       
  2. Shawn Lipscomb 2012-03-21

    I think this will break *all* apps that use "auto" for heights and widths. Is there a guide or documentation for the changes made by the new Composite Layout behavior?
  3. Shawn Lipscomb 2012-03-22

    Having "auto" mean FILL seems like a poor choice, and I'm sure Appcelerator is going to hear about it from a lot of developers. While the FILL feature is good, it should not be the default meaning of height:'auto'. IMO, it should have been implemented as height:'fill' as a new feature.
  4. Marshall Culpepper 2012-03-22

    We do plan to publish our documentation for this behavior, but I can explain it our "auto" behavior a little further here: With our new composite layout work, we have classified "auto" layout behavior into two categories: * FILL (fills the parent container) * SIZE (constrains to child view content) In Titanium, "auto" could either mean FILL or SIZE, depending on the View type, and the platform. Some examples * A Ti.UI.View in Android would by default have FILL behavior for "auto", while iOS would have default SIZE behavior * WebViews have FILL behavior on both platforms * ImageViews have SIZE behavior on both platforms Even when the cross-platform behavior was consistent, we needed to clearly classify what "auto" meant for every view type in our system. Because of these inconsistencies, we are actually deprecating "auto" altogether in favor of explicit FILL or SIZE. "auto" won't be going away in 2.0, but explicitly using one of these two constants will be the preferred method moving forward, because it reduces confusion on what the behavior of "auto" actually means.
  5. Shawn Lipscomb 2012-03-22

    Marshall, thanks for explaining. I personally think that Ti.UI.View's 'auto' behavior being different between Android and iOS is a mistake, since everyone is forced to change as soon as they get 2.0, but as long as it's documented that you should basically change all of your 'auto's to explicit FILL or SIZE, that should suffice. Thanks again.
  6. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source