How to hide the title bar while application is loading and show it when it finishes loading?

Posted by Arci on Stack Overflow See other posts from Stack Overflow or by Arci
Published on 2011-11-27T17:44:12Z Indexed on 2011/11/27 17:49 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

I have an application which uses a custom title bar. However, when my application launches, I noticed that the default title bar is shown for a brief period of time. My problem is I don't want to show the default title bar while my application is loading. How do I hide the title bar while my application is loading so that there will be no hint of it and then show it afterwards?

So far, I tried the following solutions but none have worked:

  • Hide the title bar in XML and then set the custom title bar in code. (Problem encountered: I received an error message saying: "You cannot combine custom titles with other title features".)

In XML:

<item name="android:windowNoTitle">true</item>

In onCreate method:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
//... some code goes here
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_header);
  • Set the size of the title bar in XML to 0. Then change it's size via code later. (Problem encountered: I don't know how to set the size of title bar in code. Is it possible? I tried getWindow().setAttributes() and getWindow().setLayout() but both of them didn't worked.)"

In XML:

<item name="android:windowTitleSize">30dp</item>
  • Modify windowTitleBackgroundStyle and set a transparent drawable as background. (Problem encountered: The content of the title bar became invisible but a line below the title bar is still visible.)

In XML:

<!-- style used by windowTitleBackgroundStyle -->
<item name="android:background">@drawable/transparent</item>

© Stack Overflow or respective owner

Related posts about android

Related posts about gui