Is there any way to force stacked tabs? I want tabs separate of action bar (in a second row), even when landscape mode.
I am trying to force it but I can´t. For example, Twitter app in Android, when change to lanscape mode, continue showing two rows (tabs in a separate rows, which are known as stacked tabs).
Thanks!
1 First of all type chrome://flags/ in Google Chrome addressbar and press Enter. It'll open advanced configuration page. 2 Press " Ctrl+F " keys together to launch find box and type following in the find box: Stacked Tabs It'll highlight an option with the same name. ... 3 Click on the " Enable " link given below the option. More items...
They shrink the tabs to a pre-defined size and once they reach that size limit, they start stacking new tabs to the right and small arrow icons are shown on the tab bar to navigate between tabs. It helps in easily switching between running tabs.
Click and start dragging one tab over another or over an existing Tab Stack; When the second tab is dimmed, release the mouse button. You can adjust Stacking Drop Delay in Settings > Tabs > Tab Features > Tab Stack Options. Make it longer, if you often accidentally create Tab Stacks, when dragging tabs from one place on the Tab Bar to another.
When the Tab Stack is expanded, the tabs in the stack will share the available space on the Tab Bar with all other tabs. The stack will expand automatically when viewing a tab in the stack and collapse, when viewing other tabs. To keep the Tab Stack open, click on the Expand/Reduce Tab Stack button or double click on the collapsed Tab Stack.
Not only can you not force stacked tabs, you can't even force tabs -- Android can and will replace them with a drop-down list for navigation in some screen sizes and orientations.
Your only solution is to move away from action bar tabs, such as by using ViewPager
and PagerTabStrip
.
I had luck using the following reflection 'hack':
private void forceStackedTabs() {
ActionBar ab = getSupportActionBar();
if ( ab instanceof ActionBarImpl ) {
// Pre-ICS
disableEmbeddedTabs( ab );
} else if ( ab instanceof ActionBarWrapper ) {
// ICS
try {
Field abField = ab.getClass().getDeclaredField( "mActionBar" );
abField.setAccessible( true );
disableEmbeddedTabs( abField.get( ab ) );
} catch (NoSuchFieldException e) {
Log.e( TAG, "Error disabling actionbar embedded", e );
} catch (IllegalArgumentException e) {
Log.e( TAG, "Error disabling actionbar embedded", e );
} catch (IllegalAccessException e) {
Log.e( TAG, "Error disabling actionbar embedded", e );
}
}
}
private void disableEmbeddedTabs(Object ab) {
try {
Method setHasEmbeddedTabsMethod = ab.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class);
setHasEmbeddedTabsMethod.setAccessible(true);
setHasEmbeddedTabsMethod.invoke(ab, false);
} catch (Exception e) {
Log.e( TAG, "Error disabling actionbar embedded", e );
}
}
Please note that I didn't think of this myself, but simply rewrote the code given in this answer: replicate ActionBar Tab(s) with custom view
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With