【问题标题】:How to change color of actionbar in android? [closed]如何在android中更改操作栏的颜色? [关闭]
【发布时间】:2015-03-09 07:06:43
【问题描述】:

我想用十六进制颜色代码更改操作栏的颜色。请帮助我逐步更改操作栏的颜色。我是 Android 新手。请告诉我所有步骤以及更改颜色的说明。

【问题讨论】:

  • Please help me with step by step procedure不是教程网站

标签: android colors android-actionbar


【解决方案1】:

您可以在 style.xml 文件中定义自己的样式

<resources>
    ...
    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    </style>

    <style name="ActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:background">HEX_COLOR_CODE</item>
    </style>
    ...
</resources>

但它仅适用于 11 API 级别。此外,您可以使用工具栏并为其设置背景。

或者如果你想在你的代码中改变它

ActionBar actionBar = getActionBar(); //for app compat - call getSupportActionBar()
    actionBar.setHomeButtonEnabled(true);
ColorDrawable colorDrawable = new ColorDrawable(
            Color.parseColor("#0086D4"));
actionBar.setBackgroundDrawable(colorDrawable);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    • 2017-01-29
    相关资源
    最近更新 更多