Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9880] Android: custom title bar is not updated on device orientation change

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 2.1.0, Release 2.0.1, Release 3.2.0
Fix Version/sn/a
ComponentsAndroid
LabelsRTN, api, supportTeam
ReporterDavide Cassenti
AssigneeYordan Banev
Created2012-07-05T09:14:38.000+0000
Updated2020-01-09T22:21:28.000+0000

Description

Problem description

When a custom background image is set for the title bar in Android, the image is not updated when the device is rotated. Opening a window with the right orientation, opens the right image inside the drawable-land or drawable-port directory, but that is not updated when orientation changes after the window has been open.

Steps to reproduce

1. Create an app with the code below:
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();

var win1 = Ti.UI.createWindow({
	navBarHidden: true,
	tabBarHidden: true,
});

var win2 = Ti.UI.createWindow({
	navBarHidden: false,
	tabBarHidden: true,
	backgroundColor: 'white',
	title: null
});

var btn = Ti.UI.createButton({
	title: 'Open'
});

btn.addEventListener('click', function() {
	tabGroup.activeTab.open(win2, {
		animated: true
	});
});
win1.add(btn);

var tab1 = Titanium.UI.createTab({  
    title:'Tab 1',
    window:win1
});
tabGroup.addTab(tab1);  
tabGroup.open();
2. Be sure to put 2 different images (one large for landscape, one narrow for portrait) for the title bar under: - platform/android/res/drawable-land/fullnavimage.png - platform/android/res/drawable-port/fullnavimage.png 3. Set a custom theme by creating a platform/android/res/values/themes.xml file like this:
<resources>
	<!-- Changes the background of the title bar -->
     <style name="CustomWindowTitleBackground">
           <item name="android:background">@drawable/fullnavimage</item>
     </style>
     
    <style name="MyThemes" parent="android:Theme">
    	<item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">45dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
    </style>

    <style name="Theme.Titanium" parent="android:Theme.NoTitleBar"></style>
</resources>
4. Open the app with the device in portrait and click the 'Open' button 5. Rotate the device in landscape: the customized title bar does not change, but the portrait one appeares stretched. 6. Keeping the device in landscape, go back, click 'Open' again: the custom image now shows correctly, but going back to portrait gives the same problem as in #5

Expected result

Rotating the device shows the correct customized image

Comments

No comments

JSON Source