I have the same problem also. In iOS everything looks fine. But in android ionic moves the tabs to the top which hide the sub-header.
The CSS workaround solves the problem. I personally chose to replace the sub-header with a div that sits at the top of ion-content, it looks fine unless you have “pull to refresh”… it pulls down the div also and it doesn’t look nice.
I also think this is a problem in ionic and should be fixed.
We’re also stuck on this… it seems like I should just be able to have a tab bar then my view should be able to do something like:
<ion-view view-title="whatever">
<ion-header-bar class="bar bar-subheader">
<span>Some kind of magic header... probably some kind of button bar to toggle views</span>
</ion-header>
<ion-content class="has-subheader">
<span>super duper content<span>
</ion-content>
</ion-view>
As others have observed, it works fine on iOS, but Android moves the tab bar to the top and covers up the ion-header-bar… what’s interesting is the space for the header bar is properly inserted between the tab bar and the content… but the ion-header-bar is still stuck under the tab bar.
Having to tweak the css to account for this fairly typical scenario seems to defeat the glory of the ionic framework some…
All that to say, I agree with @lupo1 – is this recognized as an issue and is it going to be fixed?
The solution to this depends on your starter. If you use the tabs starter, this won’t work because a lot of cases your tabs html is outside (a parent) of your view HTML. There’s no way in CSS to target a parent selector. You have to add a class when you are on a tab with a subheader. Here’s a simple enough fix.
CSS: .tabs-top.subheader > .tabs { top: 90px; }
JS:
angular.module('myApp').run(function ($rootScope, $state, $log) {
$rootScope.$on('$stateChangeSuccess', function () {
$log.log($state.current.name);
var tabs = angular.element(document.querySelector(".tabs-top"));
//Important!!!! Put the state name you want this script to run on.
if ($state.current.name == "tab.chats") {
tabs.addClass('subheader');
}
else {
tabs.removeClass('subheader');
}
});
});
You’ll either have to switch tabs or restart your ionic serve to get this to work.
This didn’t quite work for me. The content moved down to make room for the subheader, but the subheader remained hidden. I looked with the Chrome console, and the subheader does not have the “.has-tabs-top” class assigned to it. So I changed the css to:
.platform-android .bar-subheader {
top:93px !important;
}
and it works OK