ActionBar默认颜色

时间:2012-10-10 17:03:43

标签: android colors

我正在使用操作栏作为屏幕顶部并在那里有按钮。我想在底部添加一些额外的按钮序列,但是它有太多的控件可以放入Action Bar中,所以我正在创建一个自定义视图和布局。我正在尝试匹配hte Action Bar的配色方案,但我无法弄清楚Action Bar的默认Android.R.Color是什么。

我已经设置了自定义视图的布局,如图所示。 light_gray似乎没有内置颜色,或任何表示菜单或操作栏默认颜色的内容。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
   <solid android:color="@android:color/darker_gray" />
   <stroke android:width="1dip" android:color="#333333"/>
</shape>

Screenshot of difference between top and bottom

2 个答案:

答案 0 :(得分:6)

您可以通过查看android SDK平台文件夹中的styles.xml来检查所有样式。如,

<your-sdk-dir>/platforms/android-16/data/res/values/styles.xml

查看API级别16,这就是我所看到的,

<style name="Widget.ActionBar">
    <item name="android:background">@android:drawable/action_bar_background</item>
    ...

如果该资源不公开,最好的办法是将操作栏背景和页脚背景设置为您定义的内容。您可以通过在styles.xml中创建主题并覆盖操作栏样式

来完成此操作
<style name="Theme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

现在创建实际的操作栏样式

<style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/my_background</item>
</style>

现在将此样式分配给您的应用程序,

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

答案 1 :(得分:0)

我发现自己在xml文件中寻找颜色值。我无法找到它。最后,最愚蠢的想法是最好的:

在gimp中打印模拟器和颜色选择器的屏幕。这与我一直在寻找的颜色完全匹配。

对我来说,这个答案真的很愚蠢。然而,在一天结束时,我能够很快找到价值。