Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10795] Android: Ti.UI.SIZE on a view does not work with layout property set

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-09-11T15:14:50.000+0000
Affected Version/sRelease 2.1.2
Fix Version/sRelease 3.0.0
ComponentsAndroid
LabelsSupportTeam, core, module_views, qe-testadded
ReporterVarun Joshi
AssigneeAllen Yeung
Created2012-09-06T10:13:41.000+0000
Updated2013-10-04T07:04:49.000+0000

Description

Issue

When a view has its width set to Ti.UI.SIZE, along with a layout of horizontal, the width does not wrap to the size of its child containers, instead filling out the parent that it is placed into (on Android). On iOS, the width wraps around fine.

Sample Code

{noformat} Titanium.UI.setBackgroundColor('#000'); var win1 = Titanium.UI.createWindow({ backgroundColor : 'gray' }); win1.open(); var createLogoView = function() { return Ti.UI.createImageView({ image : 'KS_nav_ui.png', height : '26dp', left : 0, borderColor : 'green', borderWidth : 1 }); } var createInfoIcon = function() { return Ti.UI.createImageView({ image : 'KS_nav_ui.png', height : '15dp', left : 0, borderColor : 'blue', borderWidth : 1 }); } var createHeaderContainer = function(leftView, rightView) { //We won't know the width of the leftView, so we want this container to be SIZE, //as we want the left and right views to be pressed up against each other horizontally, //but the overall container to be centered in the navBar. var headerContainer = Ti.UI.createView({ height : Ti.UI.SIZE, width : Ti.UI.SIZE, layout : 'horizontal', borderColor : 'red', borderWidth : 1 }); headerContainer.add(leftView); headerContainer.add(rightView); return headerContainer; } //NavBar color strip var createNavBar = function() { var navBar = Ti.UI.createView({ height : '44dp', width : Titanium.Platform.displayCaps.platformWidth, top : 0, backgroundGradient : { type : 'linear', startPoint : { x : '0%', y : '0%' }, endPoint : { x : '0%', y : '100%' }, colors : [{ color : "#4199f2", offset : 0.0 }, { color : "#3074b8", offset : 1.0 }] } }); // Container holding the logo and info icon -- Should be centered, but ends up on left side of screen on Android var logoContainer = createHeaderContainer(createLogoView(), createInfoIcon()); navBar.add(logoContainer); return navBar; } win1.add(createNavBar()); {noformat} This issue did not exist in Release 2.1.0.GA. Attached is the screenshot of how it looks like in Android.

Attachments

FileDateSize
Screen Shot 2012-09-06 at 10.09.27 AM.png2012-09-06T10:13:41.000+000018870

Comments

  1. Anshu Mittal 2012-10-25

    Tested with: SDK:3.0.0.v20121024144610 Studio: 3.0.0.201210220122 Device:HTC Desire V(Android 4.0.3) Ti.UI>SIZE works properly with layout property set.

JSON Source