Search code examples
androidlayouttitlebar

Android: Custom Title Bar


I have a custom title bar

 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
 setContentView(R.layout.activities);
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

Which works basically fine. The problem is that until the above code is called the default title bar is shown. I don't want a title bar there at all, in other words before mine shows up no title shall show up.

Adding this to the manifest:

<application android:theme="@android:style/Theme.NoTitleBar">

leads to a force close. My manifest looks like this

<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:theme="@style/My_Theme">

Where I need my_Theme since it sets the background color, setting the background color in my customer theme leads to a gray area around my colored backround. So even without the force close I am not sure if the no title will help.

Any idea?


Solution

  • I had the same issue as you.

    The issue is with something you have in your style.

    Try this out:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="My_Theme">
            <item name="android:windowTitleSize">35dp</item>
            <item name="android:windowTitleBackgroundStyle">@android:color/black</item>
        </style>
    </resources>