I can hide the action bar in honeycomb using this code:
getActionBar().hide();
But when the keyboard opens, and user copy-pastes anything, the action bar shows again. How can I disable the action bar permanently?
I can hide the action bar in honeycomb using this code:
getActionBar().hide();
But when the keyboard opens, and user copy-pastes anything, the action bar shows again. How can I disable the action bar permanently?
With the Android Studio default generated Activity superclass is
ActionBarActivity
and then, none of solution in other responses works. To solve just change superclass:to:
in the onCreate function add the following code
and just import android.support.v7.app.ActionBar
I use this solution:
in the manifest, inside your activity tag:
and in strings.xml:
This way you keep ActionBar (or Toolbar) with the title, but when Activity if created the title is automatically empty.
If you just want a theme with no action bar you can use 'NoActionBar' variant, for eg. if your base theme is as below
then you can use
But if you want to retain the properties of your main theme i.e. AppTheme you can do as below
You can retain all the properties of your base theme this way and don't have to explicitly add them in your NoActionBar theme :)
Below are the steps for hiding the action bar permanently:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
.Now replace the parent with any other theme that contains "NoActionBar" in its name.
a. You can also check how a theme looks by switching to the design tab of activity_main.xml and then trying out each theme provided in the theme drop-down list of the UI.
If your MainActivity extends AppCompatActivity, make sure you use an AppCompat theme.
If you are using
Theme.Holo.Light
and want to use theTheme.Holo.Light.NoActionBar
variant on pre 3.2 devices you can add this to yourstyles.xml
:and then set it as your activity's theme: