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();

Demo


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.


Share

You are always welcome to provide your comments and feedback from comment box.

Reference
Action Up Hide and Show
[pgwriteforus]
[pgfeedback]

Related Articles

Author: Android Guru

Share This Post On
468 ad
Join now to get more access to our Android Tutorials

Join now to get more access to our Android Tutorials

Once you Join, you will receive Mail containing latest Android Tutorials once a month !!

I promise I wont spam you !!

You have Successfully Subscribed!

Pin It on Pinterest

Shares