[TIMOB-26460] Android: Toolbar height set to Ti.UI.SIZE won't resize when changing orientation
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-10-25T14:06:28.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | android, orientation, toolbar |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2018-10-18T01:23:25.000+0000 |
Updated | 2018-10-25T18:02:53.000+0000 |
Description
*Summary:*
Android Toolbars (and ActionBars) are supposed to use a height of
56dp
for portrait orientation and 48dp
for landscape. If a Toolbar's "height" is set to Ti.UI.SIZE
(the default), then the height and its font size should automatically change when the orientation changes. It currently does *not*.
*Steps to reproduce:*
Position an Android device in portrait.
Build and run the below code on that Android device.
Note the height of the top toolbar.
Rotate the device to landscape.
Notice that toolbar height does not shrink. _(This is the bug.)_
Keep holding the device at landscape and back out of the app.
Launch the app in landscape form.
Notice that the toolbar height is smaller upon launch.
Rotate the device to portrait.
Notice that the toolbar height has not increased. _(This is the bug.)_
var window = Ti.UI.createWindow({
theme: "Theme.AppCompat.NoTitleBar",
});
var toolbar = Ti.UI.createToolbar({
title: "My Toolbar",
top: 0,
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
});
window.activity.supportToolbar = toolbar;
window.add(toolbar);
window.open();
*Cause:*
The height is not changing because Titanium override the activity's "configChanges" for orientation in the "AndroidManifest.xml". This is needed to prevent the UI from being torn down upon orientation change. Google designed it to reload UI from XML, but since Titanium's UI is generated dynamically via code, this is not an option. We have to resize the height ourselves.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10383
*FR Passed* Waiting on Jenkins to merge
Verified the fix on sdk 7.5.0.v20181025085349. Toolbar height resized on orientation change. Closing.