Reputation: 11350
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?
Upvotes: 5
Views: 3778
Reputation: 2290
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();
}
Upvotes: 5
Reputation: 11509
That is because the ActionBar wasn't added until Android 3.0 (API level 11) so any version of Android lower than that will have a title bar, not an action bar.
The ActionBar is not yet a part of the official compatibility library, so in the mean time, the ActionBarSherlock library will allow you to have an ActionBar that looks the same across all API versions.
If you want to hide the ActionBar completely just add adding android:style/Theme.Holo.NoActionBar to the activities in the manifest.
Upvotes: 4