{ "id": "116874", "key": "TIMOB-14506", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2013-07-03T21:03:53.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "parity" ], "versions": [ { "id": "15478", "description": "Release 3.1.1", "name": "Release 3.1.1", "archived": true, "released": true, "releaseDate": "2013-06-17" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:04:12.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "12305", "name": "Core", "description": "Central component of the Platform (outside of Tooling, or platform specific implementation details)" } ], "description": "A label's auto-size behavior different on Android / iOS. iOS has the expected behavior. On android, when the label's width shrinks and the text is word-wrapped, the label's width doesn't match what is displayed on screen when the word-wrapping results in a smaller width that the width change that caused the word-wrapping.\r\n\r\nI know that's a mouthful, but hopefully the code below will make it clear why android is broken.\r\n\r\nClicking the label will alert with the current vwScreen.width and label.width, then shrink the vwScreen.width by 5%. So as you click the label multiple times, the label will start to word wrap.\r\n\r\nWhen you run the code below on iOS iPhone 5 simulator and click the label, you'll see the first three values are:\r\nvwScreen.width, label.width\r\n320, 310\r\n304, 194\r\n304, 194\r\n\r\nThe point here is that the label's width is exactly the width of the text.\r\n\r\nOn Android, the same word-wrapping happens correctly, but the label's width property remains larger, always equal to the containing view. The first three values on my Android emulator are:\r\n480, 480\r\n456, 456\r\n433, 433\r\n\r\nI have labels that I want to horizontally center, and because of this bug I cannot do so on android.\r\n\r\n{code:javascript}\r\nvar isIOS = (Ti.Platform.name === 'iPhone OS');\r\n\r\nvar window = Ti.UI.createWindow({\r\n\tfullScreen : false,\r\n\ttitle : 'Label Auto Size Bug',\r\n\tbackgroundColor : 'white',\r\n\tmodal : true,\r\n\texitOnClose : true,\r\n\tnavBarHidden : true\r\n});\r\n\r\nvar vwScreen = Ti.UI.createView({\r\n\tleft : 0,\r\n\ttop : 0,\r\n\twidth : Ti.Platform.displayCaps.platformWidth,\r\n\theight : Ti.Platform.displayCaps.platformHeight,\r\n\tbackgroundColor: \"#FF0000\"\r\n});\r\nwindow.add(vwScreen);\r\n\r\nvar lblInfo = Ti.UI.createLabel({\r\n\tcolor : 'white',\r\n\tleft : 0,\r\n\ttop : 100,\r\n\theight : Ti.UI.SIZE,\r\n\twidth : Ti.UI.SIZE,\r\n\tbackgroundColor: \"#0000FF\",\r\n\ttext : '4112 N HIGH SCHOOL RD, INDIANAPOLIS, IN',\r\n\tfont : {\r\n\t\tfontSize : isIOS ? 15 : 35,\r\n\t\tfontWeight : 'bold'\r\n\t}\r\n});\r\n\r\nlblInfo.addEventListener('click', function() {\r\n\talert('vwScreen.rect.width = ' + vwScreen.rect.width + ' lblInfo.rect.width = ' + lblInfo.rect.width);\r\n\tvwScreen.width = vwScreen.rect.width * 0.95;\r\n});\r\n\r\nvwScreen.add(lblInfo);\r\nwindow.open();\r\n{code}", "attachment": [], "flagged": false, "summary": "TiAPI: Label auto-size behavior different on Android / iOS", "creator": { "name": "strautman", "key": "strautman", "displayName": "Steve Trautman", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "strautman", "key": "strautman", "displayName": "Steve Trautman", "active": true, "timeZone": "America/New_York" }, "environment": "Titanium Studio, build: 3.1.1.201306112235\r\nSDK 3.1.1.GA\r\nandroid device Samsung Galaxy Nexus, android emulator 854, iPhone 5 simulator", "comment": { "comments": [ { "id": "261189", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It seems to word-wrap correctly when anyDensity is true. When it's false, the word-wrap is per-character.\n\nThe behavior of Ti.UI.SIZE does appear to be different between the platforms.\n\nIn fact, Android seems to be correct - Ti.UI.SIZE should fill the width to the containing view. That happens on Android. On iOS, the width is sized to the containing text rather than vwScreen.\n\nTested on Samsung Galaxy S2 2.3.6, Ti SDK 3.1.1 GA.", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-09T23:18:49.000+0000", "updated": "2013-07-09T23:18:49.000+0000" }, { "id": "261783", "author": { "name": "strautman", "key": "strautman", "displayName": "Steve Trautman", "active": true, "timeZone": "America/New_York" }, "body": "\"In fact, Android seems to be correct - Ti.UI.SIZE should fill the width to the containing view.\"\r\n\r\nNo, you describe Ti.UI.FILL behavior. http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI-property-FILL says \"the view will grow its size to fill its parent\". Ti.UI.SIZE should \"constrain its size fit its contents.\" http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI-property-SIZE.\r\n\r\nAndroid is incorrect, iOS is correct.", "updateAuthor": { "name": "strautman", "key": "strautman", "displayName": "Steve Trautman", "active": true, "timeZone": "America/New_York" }, "created": "2013-07-15T13:19:43.000+0000", "updated": "2013-07-15T13:19:43.000+0000" }, { "id": "261834", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Yes you're right, my bad. The issue is still on track to be reviewed by our engineering team.\n\nThanks.", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-15T18:19:40.000+0000", "updated": "2013-07-15T18:19:40.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }