颜色“splitActionBarWhenNarrow”底部操作栏

时间:2014-11-12 12:59:20

标签: android contextual-action-bar

我有一个MainActivity扩展ActionBarActivity,我想为我的操作栏上色我使用自定义样式,我使用的自定义样式需要Api 11的问题至少我尝试过使用:

getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0099cc"))); 

但是Bottom ActionBar没有着色enter image description here

这是我的Style.xml:     

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">

    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

1 个答案:

答案 0 :(得分:2)

如果你想为你的分割动作栏上色,你将不得不使用android:backgroundSplit。以下代码可以帮助您。

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#9933CC</item>  
    <item name="android:backgroundSplit">#9933CC</item>
    <item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>


</style>

<style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:typeface">monospace</item>
    <item name="android:textStyle">bold</item>
</style>