{ "id": "63483", "key": "TIMOB-2851", "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": [ { "id": "12077", "description": "", "name": "Sprint 2011-37", "archived": true, "released": true, "releaseDate": "2011-09-19" }, { "id": "11331", "description": "", "name": "Release 1.8.0", "archived": true, "released": true, "releaseDate": "2011-10-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-09-28T13:59:28.000+0000", "created": "2011-04-15T03:31:10.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "stage" ], "versions": [ { "id": "11260", "description": "", "name": "Release 1.6.2", "archived": true, "released": true, "releaseDate": "2011-04-20" } ], "issuelinks": [], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-11-01T00:09:37.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

The specific problem relates to an issue where Android will not\r\ndisplay a view instantiated at 0.0 opacity. In addition, animation\r\nworks strangely even when instantiating at > 0.0 opacity.

\r\n

Sidebar: An additional expectation may lie in the necessity to\r\nset the view's opacity after the animation completes. Should the\r\nproperty be set by the completion of the animation, or leave this\r\nto the developer?

\r\n

Please note that the Android example uses a workaround for\r\nissue: \r\nhttps://appcelerator.lighthouseapp.com/projects/32238/tickets/2776-android-animation-callback-is-called-multiple-times

\r\n

Comparison between iOS and Android @ 1.6.0 (HTC Evo 2.2)

\r\n
\r\n// iOS / Ti 1.6.0:\r\n// Red box displays at 0.0 opacity. Use toggle button to fade in and fade out view.\r\n\r\nvar win = Ti.UI.createWindow({ backgroundColor:'#000' });\r\nvar view = Ti.UI.createView({ backgroundColor:'#f00', opacity:0.0, width:100, height:100 });\r\nvar toggleBtn = Ti.UI.createButton({ width:200, height:30, bottom:10, title:'toggle opacity' });\r\n\r\nfunction toggleOpacity(e) {\r\n    view.animate({ opacity:(view.opacity === 0.0) ? 1.0 : 0.0, duration:1000 }, function(e) {\r\n        view.opacity = (view.opacity === 0.0) ? 1.0 : 0.0;\r\n            Ti.API.info(view.opacity);\r\n    });\r\n}\r\n\r\ntoggleBtn.addEventListener('click', toggleOpacity);\r\n\r\nwin.add(view);\r\nwin.add(toggleBtn);\r\nwin.open();\r\n
\r\n
\r\n// iOS / Ti 1.6.0:\r\n// Red box displays at 1.0 opacity. Use toggle button to fade out and fade in view.\r\n\r\nvar win = Ti.UI.createWindow({ backgroundColor:'#000' });\r\nvar view = Ti.UI.createView({ backgroundColor:'#f00', opacity:1.0, width:100, height:100 });\r\nvar toggleBtn = Ti.UI.createButton({ width:200, height:30, bottom:10, title:'toggle opacity' });\r\n\r\nfunction toggleOpacity(e) {\r\n    view.animate({ opacity:(view.opacity === 0.0) ? 1.0 : 0.0, duration:1000 }, function(e) {\r\n        view.opacity = (view.opacity === 0.0) ? 1.0 : 0.0;\r\n            Ti.API.info(view.opacity);\r\n    });\r\n}\r\n\r\ntoggleBtn.addEventListener('click', toggleOpacity);\r\n\r\nwin.add(view);\r\nwin.add(toggleBtn);\r\nwin.open();\r\n
\r\n
\r\n// Android 2.2 HTC Evo / Ti 1.6.0\r\n// Red box displays at 1.0 opacity. Toggle button will successfully fade.\r\n// After fade, toggle button will not work until the second press. Fade back in.\r\n// Next press will fade out to 0.0. Rinse, repeat. :-)\r\n\r\nvar win = Ti.UI.createWindow({ backgroundColor:'#000' });\r\nvar view = Ti.UI.createView({ backgroundColor:'#f00', opacity:1.0, width:100, height:100 });\r\nvar toggleBtn = Ti.UI.createButton({ width:200, height:30, bottom:10, title:'toggle opacity' });\r\n\r\nfunction toggleOpacity(e) {\r\n    var counter = 0;\r\n    \r\n    view.animate({ opacity:(view.opacity === 0.0) ? 1.0 : 0.0, duration:1000 }, function(e) {\r\n        if (counter === 0) {\r\n            Ti.API.info('This is only called once due to the counter.');\r\n            \r\n            view.opacity = (view.opacity === 0.0) ? 1.0 : 0.0;\r\n            \r\n            Ti.API.info(view.opacity);\r\n            \r\n            counter ++;\r\n        }\r\n    });\r\n}\r\n\r\ntoggleBtn.addEventListener('click', toggleOpacity);\r\n\r\nwin.add(view);\r\nwin.add(toggleBtn);\r\nwin.open();\r\n
{html}", "attachment": [], "flagged": false, "summary": "Android: Opacity property and animation not working as expected.", "creator": { "name": "fspencer", "key": "fspencer", "displayName": "Fred Spencer", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "fspencer", "key": "fspencer", "displayName": "Fred Spencer", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "134632", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "There is a helpdesk ticket that has encounter a similar problem where the webViews do not obey the opacity property.\r\n\r\nHere is a sample code:\r\n{code}\r\nvar win = Ti.UI.createWindow({ backgroundColor: 'black' });\r\nvar web = Ti.UI.createWebView({ backgroundColor: 'white', opacity: 0.5 });\r\nwin.add(web);\r\nwin.open();\r\n{code}\r\n\r\nhttp://support.appcelerator.com/tickets/APP-338713/tickets", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-06-01T09:55:32.000+0000", "updated": "2011-06-09T17:43:06.000+0000" }, { "id": "166464", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "We also need to test adding a view with 0 opacity and verify that it works.", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-20T16:05:28.000+0000", "updated": "2011-09-20T16:05:28.000+0000" }, { "id": "167004", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "To test, use the following in app.js:\r\n\r\n{code}\r\n// Android 2.2 HTC Evo / Ti 1.6.0\r\n// Red box displays at 1.0 opacity. Toggle button will successfully fade.\r\n// After fade, toggle button will not work until the second press. Fade back in.\r\n// Next press will fade out to 0.0. Rinse, repeat. :-)\r\n\r\nvar win = Ti.UI.createWindow({ backgroundColor:'#000' });\r\nvar view = Ti.UI.createView({ backgroundColor:'#f00', opacity:1.0, width:100, height:100 });\r\nvar toggleBtn = Ti.UI.createButton({ width:200, height:30, bottom:10, title:'toggle opacity' });\r\n\r\nfunction toggleOpacity(e) {\r\n var counter = 0;\r\n \r\n view.animate({ opacity:(view.opacity === 0.0) ? 1.0 : 0.0, duration:1000 }, function(e) {\r\n if (counter === 0) {\r\n Ti.API.info('This is only called once due to the counter.');\r\n \r\n view.opacity = (view.opacity === 0.0) ? 1.0 : 0.0;\r\n \r\n Ti.API.info(view.opacity);\r\n \r\n counter ++;\r\n }\r\n });\r\n}\r\n\r\ntoggleBtn.addEventListener('click', toggleOpacity);\r\n\r\nwin.add(view);\r\nwin.add(toggleBtn);\r\nwin.open();\r\n{code}\r\n\r\nClick on the \"toggle opacity\" button and verify that it fades in and out without any flickering", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-26T14:08:36.000+0000", "updated": "2011-09-26T14:08:36.000+0000" }, { "id": "167113", "author": { "name": "fspencer", "key": "fspencer", "displayName": "Fred Spencer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Adding a view at 0.0 and animating opacity to 1.0 doesn't appear to animate the view or show.\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({ backgroundColor:'#000' });\r\nvar view = Ti.UI.createView({ opacity:0.0, backgroundColor:'#f00', width:100, height:100 });\r\n\r\nwin.add(view);\r\n\r\nwin.open();\r\n\r\nview.animate({ opacity:1.0, duration:1000 });\r\n{code}\r\n\r\nOriginal test case shows that view is at 0.0. However, 0.0 -> 1.0 does not appear to work. After 1 second, the view appears at 1.0, but that seems to be due to the opacity set on animation callback.\r\n{code}\r\nvar win = Ti.UI.createWindow({ backgroundColor:'#000' });\r\nvar view = Ti.UI.createView({ backgroundColor:'#f00', opacity:0.0, width:100, height:100 });\r\nvar toggleBtn = Ti.UI.createButton({ width:200, height:30, bottom:10, title:'toggle opacity' });\r\n\r\nfunction toggleOpacity(e) {\r\n view.animate({ opacity:(view.opacity === 0.0) ? 1.0 : 0.0, duration:1000 }, function(e) {\r\n view.opacity = (view.opacity === 0.0) ? 1.0 : 0.0;\r\n Ti.API.info(view.opacity);\r\n });\r\n}\r\n\r\ntoggleBtn.addEventListener('click', toggleOpacity);\r\n\r\nwin.add(view);\r\nwin.add(toggleBtn);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "fspencer", "key": "fspencer", "displayName": "Fred Spencer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-27T11:48:58.000+0000", "updated": "2011-09-27T11:54:47.000+0000" }, { "id": "167253", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "Re-resolving after merge of newer fixes.", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-09-28T13:59:28.000+0000", "updated": "2011-09-28T13:59:28.000+0000" }, { "id": "168073", "author": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with 1.8.0.v20111005130613 on\nGalaxy Tab 10 3.1\nHero 2.1\niPod Touch 5.0", "updateAuthor": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-05T14:46:36.000+0000", "updated": "2011-10-05T14:46:36.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }