[TIMOB-10795] Android: Ti.UI.SIZE on a view does not work with layout property set
GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2012-09-11T15:14:50.000+0000 |
Affected Version/s | Release 2.1.2 |
Fix Version/s | Release 3.0.0 |
Components | Android |
Labels | SupportTeam, core, module_views, qe-testadded |
Reporter | Varun Joshi |
Assignee | Allen Yeung |
Created | 2012-09-06T10:13:41.000+0000 |
Updated | 2013-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
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.