Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15525] Android: Setting left + right doesn't limit width when set/left to Ti.UI.SIZE

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2013-10-24T00:18:18.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 22, 2013 Sprint 22 Core, Release 3.2.0
ComponentsAndroid
Labelsandroid, module_android, parity, qe-manualtest, qe-testadded, regression, width
ReporterFokke Zandbergen
AssigneeAllen Yeung
Created2013-10-17T13:32:58.000+0000
Updated2014-11-19T21:28:25.000+0000

Description

On iOS, setting view A's left + right and leaving/setting width to Ti.UI.SIZE will result in the width of A's parent, minus A's left + right, being used as a maximum for A's effective width. On Android, the result will be as if only left was set and the view A will be as long as it needs to be for its content, until it hits A's parent width. See the screenshots for the difference with the following code:
var win = Titanium.UI.createWindow({
    backgroundColor:'#fff'
});

var view = Ti.UI.createView({
    top: 0,
    width: 300,
    backgroundColor: '#ccc'
});

view.add(Ti.UI.createLabel({
    width: 200,

    height: 20, // Force ellipsize on iOS
    wordWrap: false,
    ellipsize: true,
    top: 100,
    text: 'WIDTH, WIDTH, WIDTH, WIDTH, WIDTH, WIDTH, WIDTH',
    backgroundColor: 'red',
    color: 'white'
}));

view.add(Ti.UI.createLabel({
    left: 50,
    right: 50,

    height: 20, // Force ellipsize on iOS
    wordWrap: false,
    ellipsize: true,
    top: 200,
    text: 'LEFT + RIGHT, LEFT + RIGHT, LEFT + RIGHT, LEFT + RIGHT',
    backgroundColor: 'green',
    color: 'white'
}));

view.add(Ti.UI.createLabel({
    left: 50,
    width: Ti.UI.FILL,
    right: 50,

    height: 20, // Force ellipsize on iOS
    wordWrap: false,
    ellipsize: true,
    top: 300,
    text: 'LEFT + FILL + RIGHT, LEFT + FILL + RIGHT, LEFT + FILL + RIGHT',
    backgroundColor: 'blue',
    color: 'white'
}));


view.add(Ti.UI.createLabel({
    left: 50,
    width: Ti.UI.SIZE,
    right: 50,

    height: 20, // Force ellipsize on iOS
    wordWrap: false,
    ellipsize: true,
    top: 400,
    text: 'LEFT + SIZE + RIGHT, LEFT + SIZE + RIGHT, LEFT + SIZE + RIGHT',
    backgroundColor: 'yellow',
    color: 'black'
}));

win.add(view);
win.open();

Attachments

FileDateSize
device-2013-10-17-153212.png2013-10-17T13:32:58.000+000021206
iOS Simulator Screen shot 17 okt. 2013 15.32.04.png2013-10-17T13:32:58.000+000011311

Comments

  1. Jamie Buckley 2013-10-18

    This does not occur in 3.0.2 and below, So it would seem that it is a regression occuring in 3.1.0
  2. Allen Yeung 2013-10-23

    https://github.com/appcelerator/titanium_mobile/pull/4828
  3. Paras Mishra 2013-10-24

    Works as expected so closing the issue. Verified fix on: Device : HTC desire V , Android version : 4.0.3 SDK: 3.2.0.v20131023222443 CLI version : 3.2.0 OS : MAC OSX 10.8.4 Alloy : 1.2.2 Appcelerator Studio, build: 3.2.0.201310181700 XCode : 5

JSON Source