How to hide and show Action Bar?
In the previous posts, we discussed how to add Action Bar, handle action items clicks and add Up button. In this post, I will teach you now how to hide and show Action Bar.
In some scenario we need to hide Action Bar to provide more space for User to work on the applications.
I would recommend you to take a look at the previous posts listed below (which are prerequisites to learn current article) so that you can learn this post with much ease.
Action Bar – Hide and Show
To hide Action Bar, invoke hide() method using getSupportActionBar( ) [getActionBar( ) in case of minSDKVersion is 11 or higher] as shown below:
getSupportActionBar().hide(); // If your minSdkVersion is 11 or higher, instead use: //getActionBar().hide();
To show Action Bar, invoke show() method using getSupportActionBar( ) [getActionBar( ) in case of minSDKVersion is 11 or higher] as shown below:
getSupportActionBar().show(); // If your minSdkVersion is 11 or higher, instead use: //getActionBar().show();
Download Source Code
Entire project is zipped and is available for download. Unzip the downloaded project and to import the project into eclipse, launch eclipse >> File >> Import.. >> Choose downloaded project(How to import android project in eclipse). If you just want to run the application in your mobile and see the output but don’t want to hit your head with source code, download application(apk) file and install it in your mobile device.Download Source Code Download Application(apk)
*apk in Android is the installation file similar to exe in windows.
If you feel this article is helpful and interesting please spread a word about it to your friends and colleagues by sharing the article in Facebook or Twitter.