【发布时间】:2015-03-09 07:06:43
【问题描述】:
我想用十六进制颜色代码更改操作栏的颜色。请帮助我逐步更改操作栏的颜色。我是 Android 新手。请告诉我所有步骤以及更改颜色的说明。
【问题讨论】:
-
Please help me with step by step procedure这不是教程网站。
标签: android colors android-actionbar
我想用十六进制颜色代码更改操作栏的颜色。请帮助我逐步更改操作栏的颜色。我是 Android 新手。请告诉我所有步骤以及更改颜色的说明。
【问题讨论】:
Please help me with step by step procedure 这不是教程网站。
标签: android colors android-actionbar
您可以在 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);
【讨论】: