23

How I can remove Action Bar on specific activity not for all application, for example I have Sign Up activity and for this activity I want to remove Action Bar

Maxim
  • 241
  • 1
  • 2
  • 6

6 Answers6

65

In your AndroidManifest.xml use NoActionBar theme for your Activity like this:

<activity android:name=".SignUpActivity"
          android:theme="@style/AppTheme.NoActionBar"/>

and in your styles.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
Yessine Mahdouani
  • 1,225
  • 12
  • 24
26

from within your activity:

getActionBar().hide();

or

getSupportActionBar().hide();

I would suggest to migrate to ToolBar, new Android API for the same purpose. The main benefit of ToolBar is that you can treat it like other views, it guarantees to you a more flexible approach.

firegloves
  • 5,581
  • 2
  • 29
  • 50
  • Why load the action bar in the activity at all, then hide it? Seems like a waste to me. Just don't include it in the layout to start with. – Jon Adams Jan 06 '17 at 17:46
  • Because if you uses a generic root layout you could have choosen to have the ActionBar everywhere to reuse the same code. – firegloves Jan 06 '17 at 17:52
4

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

3

If you have an ActionBar, you can use getActionBar().hide();
If you have a SupportActionBar, you can use getSupportActionBar().hide();

Montassir Ld
  • 531
  • 4
  • 12
1

Remove Action Bar on specific Activity go to Activity java file here your Activity class extends with AppCompatActivity remove the AppCompatActivity and extends with Activity and go to xml file and select Theme NoTitleBar or go to Manifests file select your Activity and add Theme on your Activity android:theme="@android:style/Theme.NoTitleBar"/>

Enam Butt
  • 11
  • 1
0

For kotlin you can use supportActionBar?.hide()

Abduhafiz
  • 3,318
  • 5
  • 38
  • 48