Argent
Argent

Reputation: 945

Android Studio: Remove default header

I am just beginning to learn Android Studio (version 2.0, running on Windows 7). When I create a new project (Empty Activity template) Android Studio places a header at the top of the project. How can I remove the header?

Here's a picture of the problem. I want to get rid of the 'My Greeting Card' header.

enter image description here

Upvotes: 5

Views: 15125

Answers (5)

Naishar Shah
Naishar Shah

Reputation: 35

For Newer Version

app -> res -> values -> themes -> themes.xml

In that it also depends whether the phone is in night mode or not.

Then You have to modify both the files:

  1. themes.xml
  2. themes.xml (night)

with parent="Theme.MaterialComponents.DayNight.NoActionBar"

Upvotes: 1

Maulik Dodia
Maulik Dodia

Reputation: 1659

You have to simply navigate like below....

app -> res -> values -> styles.xml

Find <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> line.

Theme.AppCompat.Light.DarkActionBar line shows, how your activity will look like.

There are lots of Themes available. Just remove DarkActionBar it and press Cntrl+Space to explore another themes. In your case, you do not want Header which is called ActionBar in Android Terminology.

So, Just change theme to Theme.AppCompat.Light.NoActionBar and you are done.

To get more deeply about how the theming work and other courses of Android, Just try Pluralsight. Go to below link and get 6 months free subscription. It is very good website to learn any technology.

Pluralsight 6 Months Subscription

Upvotes: 7

Muhammad Natiq
Muhammad Natiq

Reputation: 217

just Remove AppCompatActivity and extend it with only Activity

Upvotes: 0

vikas kumar
vikas kumar

Reputation: 11018

Well the answer is already given, but still i would like to add if you don't want any kind of actionbar on top of the activity simply do this. go to your res->values->styles.xml and add these xml code

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">#3F51B5</item>
        <!-- Light Indigo -->
        <item name="colorPrimaryDark">#3949AB</item>
        <!-- Dark Indigo -->
        <item name="colorAccent">#00B0FF</item>
        <!-- Blue -->
    </style>
    <style name="AppTheme" parent="AppTheme.Base"></style>
</resources>

and reference the theme in the style on any activity you want, like below in the manifest using android:theme=@style/AppTheme.

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".DetailActivity"
            android:parentActivityName=".MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity" />
        </activity>
    </application>

Upvotes: 3

David Hackro
David Hackro

Reputation: 3712

you can hide Toolbar using

getActionBar().hide();

or

getSupportActionBar().hide();

Upvotes: 2

Related Questions