I have an actionbar with a logo, a title, 2 tabs and a search function. On a phone (3.5") everything works fine. The actionbar has 2 lines. The logo title and the search function appear on the first line and the tabs apear on the second line.
On my tablet (7") everyting is shown on a single line. But the tabs will be convert to a list when i click the search icon.
How can i split the (sherlock)actionbar in 2 lines on my 7" tabblet? Or is there an other way to solve this problem?
In ActionBarSherlock, there is a boolean value(abs__action_bar_embed_tabs) that determine whether the Tabs should be embed in ActionBar, and this value is stored in two files.
This means Tabs will be embed only if the width of device is bigger than 480dp.
If you want to control it all by yourself, you can just create values-w480 in your own project, and set abs__action_bar_embed_tabs to false to override the value in library project.
I found a solution to separate the tabs in code.
private void embeddedTabs(Object actionBar, Boolean embed_tabs) {
try {
if (actionBar instanceof ActionBarWrapper) {
//ICS and forward
try {
Field actionBarField = actionBar.getClass().getDeclaredField("mActionBar");
actionBarField.setAccessible(true);
actionBar = actionBarField.get(actionBar);
} catch (Exception e) {
Log.e("", "Error enabling embedded tabs", e);
}
}
Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class);
setHasEmbeddedTabsMethod.setAccessible(true);
setHasEmbeddedTabsMethod.invoke(actionBar, embed_tabs);
} catch (Exception e) {
Log.e("", "Error marking actionbar embedded", e);
}
}
But now I have a new problem. The tabs don't fill the tabbar completely. Actionbar tabs don't fill the tabbar
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