Custom titlebar - system titlebar being shown for a brief moment?

Posted by user291701 on Stack Overflow See other posts from Stack Overflow or by user291701
Published on 2011-02-09T21:47:11Z Indexed on 2011/02/09 23:25 UTC
Read the original article Hit count: 172

Filed under:

Hi,

I've got a custom layout I want to use as the titlebar of my android app. The technique found (linked at the bottom) works, but the system titlebar is displayed before onCreate() is called. Obviously that looks pretty jarring, as for a moment the system titlebar is shown, then my custom titlebar is shown:

// styles.xml
<resources>
  <style name="MyTheme">
    <item name="android:windowTitleSize">40dip</item>
  </style>
</resources>

// One of my activities, MyTheme is applied to it in the manifest.
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.my_activity);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_header);
}

I could always hide the system titlebar and display my own in-line perhaps with each and every layout, but, that's not very friendly.

Thanks

http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/

© Stack Overflow or respective owner

Related posts about android