I have a custom title bar
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activities);
getWindow().setFeatureInt(Window.FEATURE
you should also check whether customTitle is supported by it or not.
Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
if (customTitleSupported) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);
}
Your App crashes because in your code you calling Title Bar from window features and in other side you disabling it through manifest. Basically You cant do this, its logically incorrect. You need to modify your title bar not to remove it.
First thing why are you using a custom title bar if your app has NoTitleBar? That is silly!
Needless to say, this is your problem and you must remove that flag.
Anyhow, the best way to add custom title bar is in xml only. This avoids your app double loading the title bar; which users will see.
../res/styles.xml
<resources>
<style name="AppTheme parent="@style/android:Theme.Light">
<item name="android:windowNoTitle">false</item>
<item name="android:windowTitleSize">30dp</item
<item name="android:windowTitleStyle">@layout/custom_title</item>
</style>
</resources>
Then you dont need that code about requestAnything.
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>
This one is the only one for me, which prevents the default-title before my custom title 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>