Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7819] Android: View - height:'auto' causing view to expand rather than contract to the size of its children

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-05-03T17:33:26.000+0000
Affected Version/sRelease 1.8.1, Release 1.8.2
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsAndroid
Labelsmodule_view, parity, qe-testadded
ReporterJon Alter
AssigneeAllen Yeung
Created2012-02-27T09:08:27.000+0000
Updated2012-05-03T17:33:26.000+0000

Description

View does not resize correctly when height set to 'auto'. It should contract to the size of its children. iPhone works correctly. See attached screenshot.

Steps to reproduce:

Step 1: run the code below. Step 2: notice that the second red block fills the bottom of the screen. It should only be ass tall as its child label as it is on the iphone in the attached screenshot.
var win = Ti.UI.createWindow({
	backgroundColor: 'white'
});
win.open();

var view1 = Ti.UI.createView({
	top: 10,
	height: 100,
	backgroundColor: 'red',
});
var label1 = Ti.UI.createLabel({
	text: 'Static',
	height: 'auto',
	width: 'auto',
	backgroundColor: 'yellow',
});

var view3 = Ti.UI.createView({
	top: 120,
	height: 'auto',
	backgroundColor: 'red',
});
var label2 = Ti.UI.createLabel({
	text: 'Auto',
	height: 'auto',
	width: 'auto',
	backgroundColor: 'yellow',
});

win.add(view1);
view1.add(label1);

win.add(view3);
view3.add(label2);

Attachments

FileDateSize
view-height-auto.jpg2012-02-27T09:08:27.000+000047261

Comments

  1. Allen Yeung 2012-03-13

    This has been fixed as a part of the composite layout behavior spec (https://wiki.appcelerator.org/display/guides2/UI+Composite+Layout+Behavior+Spec) . Views should have the fill behavior by default. So the android behavior as specified in this bug is the correct behavior and the new behavior in iOS matches this as well.
  2. Wilson Luu 2012-03-16

    Closing bug. Verified fix on: SDK build: 2.0.0.v20120316124800 Runtime: v8, rhino Titanium Studio, build: 2.0.0.201203152033 Device: Nexus S (2.3.6)
  3. Natalie Huynh 2012-05-02

    Open to update label

JSON Source