Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to to hide action bar (Theme.Holo) if Android version below 3.0

Tags:

android

I notice the action bar (Theme.Holo) looks cool only in android 3.0 or heigher, but it doesn't like nice on for example Android 2.3.

is there away to show the action bar ( Theme.Holo) based on Android version?

like image 660
user836026 Avatar asked Aug 31 '12 20:08

user836026


People also ask

How do I hide action bars?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme.

What is windowActionBar in android?

android:windowActionBar denotes property for lollipop and above only. Where as windowActionBar denotes for all versions and is retrieved from support library. Follow this answer to receive notifications.

What's action bar?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.


1 Answers

The action bar requires API 11 minimum. If you want to remove it programatically though you can use hide() in the code for that activity.

ActionBar actionBar = getActionBar();
actionBar.hide();

Not really sure what it would show for anything below 3.0, but it seems like the best place to start.

Edit:

You can check the SDK version at run time with the Build constants

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //checks if its lower than Honeycomb
    ActionBar actionBar = getActionBar();
    actionBar.hide();
}
like image 72
Tonithy Avatar answered Nov 10 '22 00:11

Tonithy