Custom title bar still shows original on startup

I am using a custom title bar in my application and everything works fine, except that when the application starts up, the original (standard) Android title bar is shown for a short time before it is replaced by my custom title bar.

This is not a problem when the application is already loaded into memory, because the "latency" is not obvious, but if the application is not already in memory, it is very obvious.

There is nothing special about the code:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);

      

I thought about changing the style to have no title for the window, and just include my custom title at the start of the layout, but that doesn't seem right.

Thanks for any pointers.

+1


source to share


4 answers


Thomas Devaux has posted an intelligent solution. It worked in my application



Change windowTitleBackgroundStyle to use "@android: color / transparency" color. Also style the text "android: windowTitleStyle" and set it to "android: textColor"> also transparent.

+1


source


For completeness of Lluis answer, here's the complete code you need to hide the default header before the custom header is initiated:



<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CustomWindowTitleStyle">
        <item name="android:textColor">@android:color/transparent</item>
    </style>

    <style name="CustomTheme" parent="@android:style/Theme.Holo">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowTitleBackgroundStyle">@android:color/transparent</item>
        <item name="android:windowTitleSize">50dp</item>
        <item name="android:windowTitleStyle">@style/CustomWindowTitleStyle</item>
    </style>

</resources>

      

+1


source


add splash screen activity before the main activity loads, there should be enough time for the next page to load correctly

0


source


Can you use the app theme to set a custom header around the world for your app? See here for a pretty good example. I had a similar problem and I seem to remember that this route fixed it.

0


source







All Articles