在我的应用程序中,我正在使用ActionBarSherlock库.我也在使用自定义标题栏.这是我的onCreate:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main_tab);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Run Code Online (Sandbox Code Playgroud)
在我的styles.mxl
<style name="MyTheme" parent="Theme.Sherlock">
<item name="android:background">#ff888888</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowTitleSize">50dp</item>
<item name="android:windowTitleBackgroundStyle">@style/windowTitleBackgroundStyle</item>
</style>
<style name="windowTitleBackgroundStyle">
<item name="android:background">#00688B</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在Manifest文件中,我使用MyTheme进行活动.
android:theme="@style/MyTheme"
Run Code Online (Sandbox Code Playgroud)
此代码适用于较低的Android版本(我已使用GB2.3.5进行了测试).但是当我使用ICS进行测试时,它崩溃了以下错误:"你无法将自定义标题与其他标题功能结合起来"我在StackOVerflow讨论中进行了彻底的讨论,但无法解决问题.解决方案尝试:1)假2)没有值-v11文件夹