CaptainNemo
CaptainNemo

Reputation: 1552

Remove header from Activity

I am using firebase UI android library and my main activity inherits from FirebaseLoginBaseActivity.

For some odd reason a title bar was added to my main view which I don't know how to get rid of since it does not appear in my layout xml.

When trying this:

super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_google_maps);

In the onCreate it fails with this message:

android.util.AndroidRuntimeException: requestFeature() must be called before adding content

When trying to set this:

android:theme="@android:style/Theme.NoTitleBar"

In the AndroidManifest.xml it fails with this message:

You need to use a Theme.AppCompat theme (or descendant) with this activity.

Upvotes: 0

Views: 1747

Answers (3)

mr.v-king
mr.v-king

Reputation: 11

If you want just to hide the titlebar, try to put this after setContentView function:

getSupportActionBar().hide();

Upvotes: 1

Alex Townsend
Alex Townsend

Reputation: 1564

Try setting your base theme to android:theme="@style/Theme.AppCompat.Light.NoActionBar" instead of android:theme="@android:style/Theme.NoTitleBar".

Upvotes: 4

Boukharist
Boukharist

Reputation: 1229

Try this :

Add this style to your styles.xml if it doesn't already exists :

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

and in your v21/styles.xml :

<style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>

and set the style this way

android:theme="@android:style/AppTheme.NoActionBar"

Upvotes: 1

Related Questions