Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26460] Android: Toolbar height set to Ti.UI.SIZE won't resize when changing orientation

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-10-25T14:06:28.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsandroid, orientation, toolbar
ReporterJoshua Quick
AssigneeJoshua Quick
Created2018-10-18T01:23:25.000+0000
Updated2018-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.

Comments

  1. Joshua Quick 2018-10-18

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10383
  2. Josh Longton 2018-10-25

    *FR Passed* Waiting on Jenkins to merge
  3. Keerthi Mahalingam 2018-10-25

    Verified the fix on sdk 7.5.0.v20181025085349. Toolbar height resized on orientation change. Closing.
       Operating System
         Name                        = Mac OS X
         Version                     = 10.13.6
         Architecture                = 64bit
       Node.js
         Node.js Version             = 8.12.0
         npm Version                 = 6.4.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Studio			      =5.1.2.201810080801
       Titanium SDK
         SDK Version                 = 7.5.0.v20181025085349
       Device               = Samsung s5 Android 6,pixel android 9 
       Emulator				= Samsung galaxy s6 android 6
       

JSON Source