【问题标题】:How can I change the style of action bar API 15如何更改操作栏 API 15 的样式
【发布时间】:2013-01-29 18:25:49
【问题描述】:

我想改变我的动作栏的样式,所以我想将动作栏下的线条颜色从 Blue 更改为 Orange ,我该怎么做?

【问题讨论】:

标签: android styles android-actionbar


【解决方案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>

【讨论】:

  • 我想改变action bar下线条的颜色而不是action bar的背景
【解决方案2】:

如果你想通过代码改变它,你可以试试这个:

getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.myninepatch));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 2016-05-12
    • 2023-03-09
    • 1970-01-01
    • 2014-08-19
    • 1970-01-01
    相关资源
    最近更新 更多