I have a typical case where I have used SherlockActionBar for horizontal scrolling. I want the title bar**(one where it depicts the android default icon and app name)** in my activity to disappear. To be more clear, I do not want the bar that is present at the top of the screen but I use a action bar next to it for navigation which is vital. How do I make the top one disappear ? Any ideas will be highly appreciated. An example image is given below :
I hope the question is clear. Feel free to ask for more.
to hide programmatically AB/ABS you can use
getSupportActionBar().hide();
if you are not using support libraries
getActionBar().hide();
otherwise
getSupportActionBar().hide();
NOTE: if your activity extends SherlockFragmentActivity then only the getSupportActionBar().hide(); method will be visible otherwise you will get only getActionBar().hide(); that works with minimum API level 11.
if you are using Action bar (API Level>11)
getActionBar().hide();
or if you are using actionbar sherelock lib (API Level <11)
getSupportActionBar().hide();
Credits goes to blackbelt(answer was delvered via comments) :
getSupportActionBar().setDisplayShowHomeEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false);
Calling these functions would remove the title bar. This removed my title bar but the action bar was safe and sound. Thanks to blackbelt.
Related
I want to hide the statusbar from all layouts on click of button.That button i have define in setting layout. But on click of hide button the status bar of current layout is getting hide but on other layout is unaffected.So let me know how to implement it on all the layouts of mu app.
Create a superclass for all Activities, call it something like BaseActivity or AbstractActivity and make each activity extend this class
In the onCreate, before setContentView, read from a database like SharedPreferences whether the status bar should be hidden. If so, then hide it.
In your Settings activity, call recreate() so that each onCreate from the previous activities are called again.
It actually depends on the version of android you are using. For example in Android 4.0 and lower you can achieve it by doing:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
For full documentation go to: https://developer.android.com/training/system-ui/status
Edit: What would be better for your button is this code:
void HideStatusBar() {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}
So, when the user clicks the button call this function. Remember this also hides the action bar or toolbar, so if you don't want that remove the actionbar.hide() part. It's nice, but unfortunately, it only works on Android 4.1 and higher, so if you are supporting lower versions too better look at the documentation for clues. Hope it helps!
I have an android activity extended from ActionBarActivity.
My Activity content ruled by state pattern. When state changes, screen also changes somehow. I need ActionBar just in one of 3 states I have. How can I hide ActionBar by default and show it only in one State of my Activity?.
Thanks in advance!
For hiding use
getSupportActionBar().hide();
and for Showing it again use
getSupportActionBar().show();
look at this example its work for me by default i hide my action bar layout after that i am showing it on user data requirements
How to hide and show action bar
I'm using ViewPager to display tabs in Android, but in a circumstance, I want to display a fragment on top of the pager/tabs, but NOT on top of the ActionBar. If I hide the action bar, they both disappear. If I don't do it, I can't find a way to get rid of pager's tab bar (or whatever it's called). Here is a visual representation of what I'm trying to achieve:
How can I hide that bar without hiding the action bar?
I think you can do it by setting a new navigation mode.
Use setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD) to hide them
Use setNavigationMode(ActionBar.NAVIGATION_MODE_TABS) to show them again
Edit:
Please note that the setNavigationMode methods are deprecated in Android Lollipop.
Reference
Use this to get rid of tabs in actionbar
setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD)
This question has been asked (for example, here Using ViewPager with Tabs without actionBar), however the answer there doesn't work. There's some links to Swipey but unfortunately the link is broken too.
The example from Android site EffectiveNavigation uses Actionbar to host the tab fragment, so obviously if I set a .NoActionBar theme, then there's no host. Any different way? Thanks.
Update screenshot of what I want to create, at the top, there's no actionbar.
Update 2 this is from the google example, there's an actionbar on top (titled "Effective navigation), which I want to get rid of
Solution of your problem is already given in http://developer.android.com/
To disableAction-bar Icon and Title, you must do two things:
setDisplayShowHomeEnabled(false); // hides action bar icon
setDisplayShowTitleEnabled(false); // hides action bar title
Follow The Steps given in Using split action bar
Write Following Code in OnCreate()
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.navigation_drawer);
getActionBar().setDisplayShowHomeEnabled(false); // hides action bar icon
getActionBar().setDisplayShowTitleEnabled(false); // hides action bar title
//rest of your code...
}
After Android updated Actionbar to Toolbar there are many changes in Actionbar Tabs.
Please follow below links to create swipable tabs in Andoid.
Design Structure :
Tabs Design Guidelines
Some of the very useful links are below. Please refer to them.
Download sample zip from below link
http://developer.android.com/samples/SlidingTabsBasic/index.html
Or Refer these links
http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html
http://www.exoguru.com/android/material-design/navigation/android-sliding-tabs-with-material-design.html
http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/
https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout
This may help you...
You can:
Use a ViewPager with a PagerTabStrip
Use a ViewPager with the TabPageIndicator class from the ViewPagerIndicator library
Use a ViewPager with other third-party tab indicators (e.g., in the "View Pagers" category at the Android Arsenal)
Use a ViewPager and design your own tabbed indicator
Use a FragmentTabHost and skip the swiping part
Along with
getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setDisplayShowTitleEnabled(false);
Use this as well
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
I want to have an action bar placed vertically(Tablet App)
Can I have this? I know the default action bar does not support this.
Can sherlock action bar?
Can any other?
I have given this time but I dont see any solution to this.
Can sherlock action bar?
No. It backports what's available in the built-in ActionBar.
Can any other?
AFAIK no library provides such functionality.
Can I have this?
Of course you can. Depending on what you use from ActionBar this could be easy. On The image you have provided there is a FrameLayout with two Buttons and additionally hidden overlay ListView after pressing bottom Button. Not too much work.