I created an app and I use this example http://developer.android.com/training/implementing-navigation/lateral.html.
when I use the onCreateOptionsMenu(Menu menu) function and menu button create its shown in the first line and the line of the tabs is one behind it. How can I make the tabs and the menu button(three dots)
be in the same line?
I tried this
requestWindowFeature(Window.FEATURE_NO_TITLE);
also this
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
and this is only removed the title and the icon and now I have one empty line with menu button(...)
this its how its look now
Thanks
This is the expected behavior for non-tablet sized screens, so unless you roll your own ActionBar-isque implementation, you can't make the top ActionBar to go away as long as you have menu items.
However if you don't need the menu button, you can remove the top ActionBar entirely through
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
Related
I want to remove my app action bar but when I tried it using this:
android:theme="#style/Theme.AppCompat.NoActionBar"
My whole app changed to sort of dark gray (pics attached)
it,s so easy in MainActivity put this line getSupportActionBar().hide();
I am trying to add few menu Items on my action Bar.
I have 5 buttons and 1 Button for searchView.
If I just put 5 Menu Items , it shows only 4 at the top and blocks away the Text of Action bar.
So I used android:uiOptions="splitActionBarWhenNarrow"
It causes the Actionbar to show on Below as well as Top. But on Bottom action bar, All i can see is 4 Buttons. There is no sign of 5th Button. How can I place 5th Button and an extra search Button on Top bar. Since there is no Menu buttons on top bar now.
Can you post a image friend?
I am guessing that you have to many MenuItems and they are just pushing the 5th away to the right because of the limited space on the action bar. It depends a little bit on what kind of ActionBar you are using, in what target and what version of Android.
Have you considered using a ActionOverflow button for listing the other options?
I am using ActionBarSherlock to implement 4 tabs in an activity. The tabs display properly in portrait mode below the action bar and scrolling works as it should. When I switch to landscape mode, the tabs are placed in a spinner (they still function correctly). How can I force the tabs to display individually in landscape mode (either in the action bar or below)?
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar.Tab tab1 = getSupportActionBar().newTab();
tab1.setText("TAB 1 TEXT");
tab1.setTabListener(this);
getSupportActionBar().addTab(tab1);
ActionBar.Tab tab2 = getSupportActionBar().newTab();
tab2.setText("TAB 2 TEXT");
tab2.setTabListener(this);
getSupportActionBar().addTab(tab2);
ActionBar.Tab tab3 = getSupportActionBar().newTab();
tab3.setText("TAB 3 TEXT");
tab3.setTabListener(this);
getSupportActionBar().addTab(tab3);
ActionBar.Tab tab4 = getSupportActionBar().newTab();
tab4.setText("TAB 4 TEXT");
tab4.setTabListener(this);
getSupportActionBar().addTab(tab4);
How can I force the tabs to display individually in landscape mode (either in the action bar or below)?
By not using action bar tabs.
The behavior you are seeing is not tied to ActionBarSherlock. ABS is mirroring the behavior of the standard action bar, which will do the same thing. This is by design. It is also stupid, IMHO, but when I filed an issue, I was told that this was working as intended.
If you want your tabs to always be tabs, use any implementation other than action bar tabs, such as a ViewPager with a tabbed indicator.
This is the default behavior for the ActionBar.
https://code.google.com/p/android/issues/detail?id=24439
I saw this
https://groups.google.com/forum/#!msg/android-developers/2unF5lKfn64/iKUX7JbbOo4J
After adding tabs to ActionBar call setNavigationMode() for tab navigation mode, e.g.
Tab tabDemo=mTabsAdapter.addTab(bar.newTab().setText("ABC"),.Abc.class, null,"Abc");
bar.setNavigationMode(ActionBar.Navigation_mode_tabs);
It shows tabs in tabbed view mode.
I don't know if it works but you can try it.
You can also create a view with tabs instead of using the ActionBar tabs. I believe you have to use ViewPager or something like that.
I am looking to hide the Sherlock action bar on single tap and show it when user does another single tap thus showing/hiding on alternating single tap.
The code for showing and hiding is:
#Override
public boolean onSingleTapConfirmed(MotionEvent e) {
ActionBar actionBar = getSupportActionBar();
if (actionBar.isShowing()) {
actionBar.hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
} else {
actionBar.show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
return super.onSingleTapConfirmed(e);
}
The above code works fine for me but the problem is the jerk seen by the user when the transition od action and notification bars occurs from shown to hidden and vice versa.
To avoid the jerk, I added the following line in the onCreate method, but it causes the action bar to cover the UI elements when the action bar comes to visible from invisible state.
requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);
Is there any way out by which the jerk is also not there and the action bar is not overlayed on the UI elements when it comes from hidden to visible state?
How about achieving the similar behavior with a sliding menu from top?
you could set roatation to SlidingDrawer and use it
android:rotation="180" // in SlidingDrawer manifest tag.
I understand that SlidingDrawer is deprecated in API 17 but you could always have a custom implementation of this. I'm sure this would be a very smooth implementation for you.
I have master detail layout in my app (see picture on the left):
I have navigation mode list set for actionbar (using it for filtering listview in second fragment):
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
I removed my activity title from actionbar with:
actionBar.setDisplayShowTitleEnabled(false);
The problem is that my drop down menu now appears above the first fragment (on the left side of the actionbar), as if it is refering to first fragment. This might confuse the user.
How can i place actionbar dropdown menu above second fragment?
there's no direct API to do what you want (move the spinner to the middle of the ActionBar)
Your best option to achieve something remotely similar to that is to create your own view with a spinner and user the setCustomView method from the actionbar.