Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

How do I add a title bar/navbar to the main window?

I'm sure I'm missing something simple, but I can't figure out how to put a navigation bar on my app's main window. My main window shows up full screen.

Here's my app.js:

var win1 = Titanium.UI.createWindow({  
    url:'mainwindow.js',
    title:'My Window Title',
    backgroundColor:'#fff'
});
win1.open();
— asked March 11th 2010 by Mark Burggraf
0 Comments

4 Answers

  • You're actually not missing something simple – it's an oddity with applications that don't use "TabGroups". I also struggled with this. I'm not sure if it's really a bug or, in fact, Titanium is mimicking precisely what native iPhone app would do in this instance (I'm assuming you're using iPhone Simulator, but the same might be true anyway for Android.)

    What the Appcelerator guys have recommended elsewhere is to create a TabGroup even if you don't really want multiple tabs. Then create just one tab (with one window) on it, but put "hideTabBar:true" in the createWindow call.

    So…

    var tabGroup = Ti.UI.createTabGroup();
    
    var myOnlyWin = Ti.UI.createWindow({
        backgroundColor: '#FFF',
        title:'Just Messing around',
        tabBarHidden:true
    });
    
    
    var tab = Ti.UI.createTab({
        title:"Doesn't matter",
        window: myOnlyWin
    });
    
    tabGroup.addTab(tab);
    tabGroup.open();
    

    So you're creating the tabgroup only because – for whatever reason – that's the automatic way to get the navbar at the top with the window title. Then, since you're not interested in having tabs, you tell the window it should hideTabBar when it's created.

    It's a strange workaround!

    — answered March 11th 2010 by Bill Dawson
    permalink
    0 Comments
  • Thanks. I thought that might be the problem (since the title bar works great in the Kitchen Sink app). I couldn't see where Kitchen Sink was declaring the title bar, so I figured it came automatically when the tabs were created. This kind of stuff really needs to be documented somewhere.

    — answered March 11th 2010 by Mark Burggraf
    permalink
    0 Comments
  • This answer is 2 years old… is there a better solution today?

    — answered March 15th 2012 by vincent youmans
    permalink
    3 Comments
    • Now 4 years old. Any better solution yet?

      — commented December 18th 2013 by Billy Jones
    • Now 5 years old.. and?

      — commented December 29th 2014 by Victor Casé
    • Now 6 years old still

      — commented September 9th 2015 by khodour fouani
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.