Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-9880

Android: custom title bar is not updated on device orientation change

    Details

    • Type: Bug
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: Release 2.1.0, Release 2.0.1, Release 3.2.0
    • Fix Version/s: None
    • Component/s: Android
    • Labels:
    • Environment:

      Titanium SDK: 2.0.1
      Platform OS: Android
      Platform OS Version: 2.2

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ybanev Yordan Banev
                Reporter:
                dcassenti Davide Cassenti
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-13982
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code