{ "id": "174212", "key": "TIMOB-27438", "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": "2019-10-02T20:10:01.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "engSchedule", "toolbar" ], "versions": [ { "id": "18414", "description": "", "name": "Release 6.2.0", "archived": false, "released": true, "releaseDate": "2017-09-13" } ], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-10-14T20:56:02.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Summary:*\r\nIf you add {{Toolbar}} to a {{Window}} after it has been opened, then {{Toolbar}} property \"extendBackground\" is ignored. The {{Toolbar}} will instead be overlapped by the top status bar.\r\n\r\n*Steps to reproduce:*\r\n# Build and run the below code on Android.\r\n# Tap on the \"Add/Remove\" button.\r\n# Notice that the toolbar added to the top is overlapped by the status bar. (This is the bug.)\r\n\r\n{code:javascript}\r\nvar wasAdded = false;\r\nvar windowSettings = {\r\n\textendSafeArea: true,\r\n};\r\nif (Ti.Android) {\r\n\twindowSettings.windowFlags = Ti.UI.Android.FLAG_TRANSLUCENT_STATUS;\r\n\twindowSettings.theme = \"Theme.AppCompat.NoTitleBar\";\r\n}\r\nvar window = Ti.UI.createWindow(windowSettings);\r\nvar toolbar = Ti.UI.createToolbar({\r\n\ttitle: \"My Toolbar\",\r\n\ttitleTextColor: \"white\",\r\n\tbackgroundColor: \"blue\",\r\n\textendBackground: true,\r\n\ttop: 0,\r\n//\tbottom: 0,\r\n\twidth: Ti.UI.FILL,\r\n});\r\nvar button = Ti.UI.createButton({\r\n\ttitle: \"Add/Remove Toolbar\",\r\n})\r\nbutton.addEventListener(\"click\", function() {\r\n\tif (wasAdded) {\r\n\t\twindow.remove(toolbar);\r\n\t} else {\r\n\t\twindow.add(toolbar);\r\n\t}\r\n\twasAdded = !wasAdded;\r\n});\r\nwindow.add(button);\r\nwindow.open();\r\n{code}\r\n\r\n*Result:*\r\n !Android-bad.png|thumbnail! \r\n\r\n*Expected Result:*\r\n !Android-good.png|thumbnail! \r\n\r\n*Recommended Solution:*\r\nOur toolbar Java code should call the [requestApplyInsets()|https://developer.android.com/reference/android/view/View#requestApplyInsets()] method when attached to the window. This requests the view hierarchy to re-dispatch the window insets to all child views, which is used to apply an internal padding to the toolbar needed to make \"extendBackground\" work.\r\n\r\nWe'll need to add something like the following to our Toolbar code.\r\n{code:java}\r\n@Override\r\npublic void onAttachedToWindow()\r\n{\r\n\tsuper.onAttachedToWindow();\r\n\r\n\tif (getFitsSystemWindows()) {\r\n\t\tif (android.os.Build.VERSION.SDK_INT >= 20) {\r\n\t\t\trequestApplyInsets();\r\n\t\t} else {\r\n\t\t\trequestFitSystemWindows();\r\n\t\t}\r\n\t}\r\n}\r\n{code}\r\n\r\n*Work-around:*\r\nAdd the {{Toolbar}} to the {{Window}} before opening it and use {{Toolbar}} methods {{show()}} and {{hide()}} to control its visibility instead.\r\n", "attachment": [ { "id": "67006", "filename": "Android-bad.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-10-02T20:01:32.000+0000", "size": 89642, "mimeType": "image/png" }, { "id": "67007", "filename": "Android-good.png", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-10-02T20:01:32.000+0000", "size": 89771, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: Toolbar \"extendBackground\" property ignored if added to window after open", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }