如何更改操作栏API 15的样式

时间:2013-01-29 18:25:50

标签: android styles android-actionbar

我想更改操作栏的样式,所以我想将操作栏下的线条颜色从蓝色更改为橙​​色,我该怎么做?

2 个答案:

答案 0 :(得分:1)

有一个很好的教程here

使用自定义可绘制

创建新样式
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="Theme.MyStyle" parent="@android:style/Theme.Holo">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <!-- other activity and action bar styles here -->
    </style>

    <!-- style for the action bar backgrounds -->
    <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:background">@drawable/ab_background</item>
        <item name="android:backgroundStacked">@drawable/ab_background</item>
        <item name="android:backgroundSplit">@drawable/ab_split_background</item>
    </style>
</resources>

然后在 AndroidManifest.xml 中添加自定义样式

<application
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"

        android:theme="@style/Theme.MyStyle"
        >
   <activity ...>
   <activity .../>
   ...

</application>

答案 1 :(得分:0)

如果您想通过代码进行更改,可以试试这个:

getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.myninepatch));
相关问题