Rectangle 27 0

Make you create custom style in values folder. Make sure you code as below.

<style name="CustomTheme" parent="android:Theme">

This did work for me.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

setContentView(R.layout.workorder_list);
this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.workorder_list_titlebar);

I am having the same issue and this didn't fix the force close.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

Since, I was trying to compile my program in android 4.0, I was facing the same problem. None of these solutions helped.So, I copied my style contents from values > styles.xml and pasted it in values-v11 styles.xml file and values-v14 styles.xml file. Bingo, the trick worked.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

The Action Bar used on Android 3.0+ is considered a title feature, and your Activity will get one by default if you are using one of the Holo themes. (Theme.Holo, Theme.Holo.Light, etc.) Theme.Holo is the default for apps with targetSdkVersion="11" or above. The older "custom title bar" feature cannot be combined with the action bar, but you can use the action bar to do this instead.

Use the action bar's list navigation mode, set using ActionBar#setNavigationMode and ActionBar#setListNavigationCallbacks to specify an adapter that will supply spinner views.

android - How do i add a spinner to the title bar of an activity? - St...

android titlebar custom-titlebar
Rectangle 27 0

create a new XML style file my_theme.xml in values folder like this:

<style name="MyWindowTitleBackground">
    <item name="android:background">#444444</item>
</style>

<style name="MyTheme" parent="android:Theme">
    <item name="android:windowTitleBackgroundStyle">@style/MyWindowTitleBackground</item>
</style>

You may define other settings as you like in this theme.

Then just use this theme in your manifest within the activity's attributes

android:theme="@style/MyTheme"

Finally set your custom title as always in your activity.java:

final Window window = getWindow();
boolean useTitleFeature = false;
// If the window has a container, then we are not free
// to request window features.
if (window.getContainer() == null) {
    useTitleFeature = window
        .requestFeature(Window.FEATURE_CUSTOM_TITLE);
}
setContentView(R.layout.screen_main);

if (useTitleFeature) {
    window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
        R.layout.custom_title);
    // Set up the custom title

    main_title = (TextView) findViewById(R.id.title_left_text);
    main_title.setText(R.string.app_name);
    main_title = (TextView) findViewById(R.id.title_right_text);
    main_title.setText(R.string.Main_titleInfo);

}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_vertical" >

    <TextView
        android:id="@+id/title_left_text"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:ellipsize="end"
        android:singleLine="true" />

    <TextView
        android:id="@+id/title_right_text"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:ellipsize="end"
        android:singleLine="true"
        android:textColor="#fff" />

</RelativeLayout>

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

I did exactly as Sunny Dasari did but with one small change I put the @ before and android in the parent attribute.

<style name="CustomTheme" parent="@android:Theme">

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

create a new XML style file my_theme.xml in values folder like this:

<style name="MyWindowTitleBackground">
    <item name="android:background">#444444</item>
</style>

<style name="MyTheme" parent="android:Theme">
    <item name="android:windowTitleBackgroundStyle">@style/MyWindowTitleBackground</item>
</style>

You may define other settings as you like in this theme.

Then just use this theme in your manifest within the activity's attributes

android:theme="@style/MyTheme"

Finally set your custom title as always in your activity.java:

final Window window = getWindow();
boolean useTitleFeature = false;
// If the window has a container, then we are not free
// to request window features.
if (window.getContainer() == null) {
    useTitleFeature = window
        .requestFeature(Window.FEATURE_CUSTOM_TITLE);
}
setContentView(R.layout.screen_main);

if (useTitleFeature) {
    window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
        R.layout.custom_title);
    // Set up the custom title

    main_title = (TextView) findViewById(R.id.title_left_text);
    main_title.setText(R.string.app_name);
    main_title = (TextView) findViewById(R.id.title_right_text);
    main_title.setText(R.string.Main_titleInfo);

}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_vertical" >

    <TextView
        android:id="@+id/title_left_text"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:ellipsize="end"
        android:singleLine="true" />

    <TextView
        android:id="@+id/title_right_text"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:ellipsize="end"
        android:singleLine="true"
        android:textColor="#fff" />

</RelativeLayout>

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

I had the same issue and I fix it deleting

<item name="android:windowNoTitle">true</item>
theme.xml

This fixed it for me, but there's a noticable Flash where the title bar still appears for a second and then hides. Any way around this?

Hi, I know this is an old post but could you help me find the theme.xml file? Its not a default xml file in my project

I don't have a theme.xml too :(

I have a styles.xml, created by the wizards, which is the same.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

I think notenking is right, that this is a problem in activities within tabs. Since some of my activities can either be stand-alone or within a tab, I've found the following helps:

final Window window = getWindow();

    boolean useTitleFeature = false;
    // If the window has a container, then we are not free
    // to request window features.
    if(window.getContainer() == null) {
        useTitleFeature = window.requestFeature(Window.FEATURE_CUSTOM_TITLE);
    }

    setContentView(layoutId);

    if (useTitleFeature) {
        window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
    }

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

setContentView(R.layout.workorder_list);
this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.workorder_list_titlebar);

I am having the same issue and this didn't fix the force close.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

I had the same issue and I fix it deleting

<item name="android:windowNoTitle">true</item>
theme.xml

This fixed it for me, but there's a noticable Flash where the title bar still appears for a second and then hides. Any way around this?

Hi, I know this is an old post but could you help me find the theme.xml file? Its not a default xml file in my project

I don't have a theme.xml too :(

I have a styles.xml, created by the wizards, which is the same.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

May be you find this problem when use it in tab,for there already have a title and you can not add a custom title again.

you should add this custom title in the activity which you get the Tab

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

For anyone interested. I got around this by declaring no title bar in the theme and adding the title bar to the main activity; and using a viewpager with fragments. So that the "title bar" is always visible.

<style name="AppTheme" parent="android:Theme.Light.NoTitleBar">
     <item name="android:windowTitleSize">35sp</item>
     <item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
     <item name="android:buttonStyle">@style/My.Button</item>
 </style>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainView">

<include layout="@layout/titlebar"/>

<android.support.v4.view.ViewPager
    android:id="@+id/contentViewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" />

 </LinearLayout>

android - Custom titlebar has unwanted black border - Stack Overflow

android custom-titlebar android-titlebar
Rectangle 27 0

Since, I was trying to compile my program in android 4.0, I was facing the same problem. None of these solutions helped.So, I copied my style contents from values > styles.xml and pasted it in values-v11 styles.xml file and values-v14 styles.xml file. Bingo, the trick worked.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

May be you find this problem when use it in tab,for there already have a title and you can not add a custom title again.

you should add this custom title in the activity which you get the Tab

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

To avoid crashing, you can simply add

android:theme="@style/android:Theme"

to the <Activity> tag in your AndroidManifest.xml:

<activity
    android:name="test.TestActivity"
    android:label="@string/app_name"
    android:theme="@style/android:Theme">

This is because the styles defined in your default theme conflict with FEATURE_CUSTOM_TITLE (such as the attribute android:windowNoTitle). By using another theme, you can avoid such problems.

However, you might further need to define your own theme to change other attributes, such as android:windowTitleSize, background color, text color and font, etc. In this case, you can derive your theme from an existing theme (e.g., Theme.Light) and modify its attributes:

<resources>
    <style name="CustomWindowTitleBackground">
        <item name="android:background">#323331</item>
    </style>

    <style name="CustomTheme" parent="@style/android:Theme.Light">
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">60dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
    </style>
</resources>

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

I have run into this issue as well and it looks like it is an issue with what theme is applied to an activity in the AndroidManifest.xml file. If I use a theme like:

android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
android:theme="@android:style/Theme.Black"

then it will not throw the error and subsequently will not crash. However I am trying to use a theme like Theme.Holo. I'm not sure if there is a way around this.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

Go to res/values folder in your android project and check for strings.xml (this file may vary in your case, something like themes.xml)

Inside the file under resource tag check whether you have style tags. If you don't find it, add the code below as mentioned below as a child to resources tag

<resources>
    <style name="SomeNameHere">
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

if you already have style tag, just add the code below to your style tag

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

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

Make you create custom style in values folder. Make sure you code as below.

<style name="CustomTheme" parent="android:Theme">

This did work for me.

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android
Rectangle 27 0

To avoid crashing, you can simply add

android:theme="@style/android:Theme"

to the <Activity> tag in your AndroidManifest.xml:

<activity
    android:name="test.TestActivity"
    android:label="@string/app_name"
    android:theme="@style/android:Theme">

This is because the styles defined in your default theme conflict with FEATURE_CUSTOM_TITLE (such as the attribute android:windowNoTitle). By using another theme, you can avoid such problems.

However, you might further need to define your own theme to change other attributes, such as android:windowTitleSize, background color, text color and font, etc. In this case, you can derive your theme from an existing theme (e.g., Theme.Light) and modify its attributes:

<resources>
    <style name="CustomWindowTitleBackground">
        <item name="android:background">#323331</item>
    </style>

    <style name="CustomTheme" parent="@style/android:Theme.Light">
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">60dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
    </style>
</resources>

android - Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You...

android