سؤال

I defined this theme in my styles.xml:

<style name="customTheme" parent="AppBaseTheme"> 
   <item name="android:windowTitleSize">40dip</item>
</style> 

In that custom theme I define a custom title bar. Apart from the custom title bar I want to keep the theme original:

parent="AppBaseTheme"

The problem is that when I try to set this custom title like this:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.activity_home);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);

I get an error on the second line which says:

You cannot combine custom titles with other title features.

How can I keep the original theme with only changing the title to my custom_title_bar layout?

هل كانت مفيدة؟

المحلول

If you call

setFeatureInt(Window.FEATURE_CUSTOM_TITLE, ...)

where ActionBar has already been set (e. g. with Holo theme), than it can cause this problem.

Try this:

<item name="android:windowActionBar">false</item>

in your custom theme.

نصائح أخرى

Customize your title bar in style of custom theme

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top