dev90
dev90

Reputation: 7519

How to remove the Action Bar from a Activity

I am trying to remove the action bar from an activity.

I have done following but its still keeping the Action bar on my Activity

public class MyActivity extends AppCompatActivity{ .. }

Layout

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".TM.TMActivity"
    style="@style/AppTheme.NoActionBar"
    >


    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="@style/AppTheme.NoActionBar"
        />

</android.support.design.widget.CoordinatorLayout>

Style.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Upvotes: 0

Views: 3115

Answers (4)

Raviraj Subramanian
Raviraj Subramanian

Reputation: 364

Check if the correct style has mentioned in the manifest file.

<application
   android:icon="@drawable/icon"
   android:label="@string/app_name"
   android:theme="@style/AppTheme">

And in your style file:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
</style>

Check your build.gradle(app) also for dependency.

compile 'com.android.support:appcompat-v7:x.x.x'

There is no need to mention style in Coordinator/Frame layout. Remove the following line from all the layout and try.

style="@style/AppTheme.NoActionBar"

Upvotes: 2

M. Wiśnicki
M. Wiśnicki

Reputation: 6203

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

In your activity You can disable.

Upvotes: 3

nkpatel
nkpatel

Reputation: 313

In styles.xml in values folder,

     <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

Upvotes: 3

N J
N J

Reputation: 27505

Use Theme.AppCompat.Light.NoActionBar its working for me

e.g

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->

</style>

Upvotes: 6

Related Questions