在自定义title时
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(layoutResID);
getWindow()
.setFeatureInt(Window.FEATURE_CUSTOM_TITLE, titleLayoutResID);
提示You cannot combine custom titles with other title features
解决 :在manifest 当前 activity theme 加上android:theme=”@style/TitleTheme”
例子:
<style name="TitleTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowTitleSize">44dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">false</item>
</style>
<style name="CustomWindowTitleBackground">
<item name="android:background">@drawable/main_title</item>
</style>