문제

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