Tae-Sung Shin
Tae-Sung Shin

Reputation: 20643

How to hide title bar from the beginning

I am using following code to replace title bar.

    final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

And it's working fine once UI loaded. Problem is however when I start the app, the ugly gray bar appears for 1-2 seconds until UI loaded. Is there any way to specify not showing the default title bar at all?

Upvotes: 6

Views: 5501

Answers (3)

iTurki
iTurki

Reputation: 16398

In the Manifest file, add this line inside the application tag

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

It will hide the bar from all the activities. If you want to hide it from a specific activity, add the same line to that activity's tag.

Good Luck !

Upvotes: 4

vanleeuwenbram
vanleeuwenbram

Reputation: 1339

You should add a line to your AndroidManifest which states that you use a theme (standard android or extended)

<application android:name=".YourAppNameHere" 
         android:label="@string/app_name" 
         android:icon="@drawable/icon" 
         android:theme="@style/MyTheme">

and then you can have a themes.xml in your res/values/ folder where you extend the: Theme.NoTitleBar and add custom rules to them (for example like windowBackground)

<resources>
 <style name="MyTheme" parent="android:Theme.NoTitleBar">
    <item name="android:windowBackground">@drawable/my_background</item>
  </style>
<resources>

Have fun

Upvotes: 1

LuxuryMode
LuxuryMode

Reputation: 33741

If you want the titlebar to be gone in every activity within your app, then add

<application android:name=".YourAppNameHere" 
             android:label="@string/app_name" 
             android:icon="@drawable/icon" 
             android:theme="@android:style/Theme.NoTitleBar">

to your manifest. Not 100% sure though that this will prevent the titlebar from showing up momentarily, but it should work.

Upvotes: 12

Related Questions