Android的无法改变动作条的背景颜色 [英] Android unable to change background color of ActionBar

查看:126
本文介绍了Android的无法改变动作条的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变我的动作条的背景颜色,但引用<一后href=\"http://stackoverflow.com/questions/8024706/how-do-i-change-the-background-color-of-the-actionbar-of-an-actionbaractivity-us\">several <一href=\"http://stackoverflow.com/questions/18288402/how-to-set-custom-actionbar-color-style?lq=1\">other在这个网站的问题我仍然不能得到他们的解决方案的工作。

Styles.xml

 &LT;资源&GT;    &LT;样式名称=AppTheme父=Theme.AppCompat.Light.DarkActionBar&GT;
        &LT;项目名称=actionBarStyle&GT; @风格/动作条&LT; /项目&GT;
        &LT;项目名称=机器人:windowActionBar&GT;真&LT; /项目&GT;
    &LT; /风格&GT;    &LT;样式名称=动作条父母=Widget.AppCompat.ActionBar.Solid&GT;
        &LT;项目名称=背景&GT; @彩色/ light_blue_menu_bar&LT; /项目&GT;
    &LT; /风格&GT;
&LT; /资源&GT;

colors.xml

 &LT;资源&GT;
    ...
    &LT;颜色名称=blue_semi_transparent_ pressed&GT;#80738ffe&LT; /彩色&GT;
    &LT;颜色名称=light_blue_menu_bar&GT;#87CEFA&LT; /彩色&GT;
&LT; /资源&GT;

的manifest.xml

 &lt;应用
        机器人:allowBackup =真
        机器人:图标=@的mipmap / ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme&GT;

然而在ActionBar没有出现在我的意见。我缺少什么?

修改

解决的办法是添加到styles.xml

 &LT;项目名称=机器人:windowActionBar&GT;真&LT; /项目&GT;


解决方案

 &LT;样式名称=AppTheme父=@风格/ Theme.AppCompat.Light.DarkActionBar&GT;
    &LT;项目名称=机器人:actionBarStyle&GT; @风格/ ActionBarStyle&LT; /项目&GT;
    &LT;项目名称=actionBarStyle&GT; @风格/ ActionBarStyle&LT; /项目&GT;
    &LT;项目名称=机器人:windowActionBar&GT;真&LT; /项目&GT;
&LT; /风格&GT;&LT;样式名称=ActionBarStyle父=Widget.AppCompat.ActionBar&GT;
        &LT;项目名称=背景&GT; @色/蓝&LT; /项目&GT;
    &LT;项目名称=机器人:背景&GT; @色/蓝&LT; /项目&GT;
&LT; /风格&GT;

I'm trying to change the background color of my Actionbar, but after referencing the several other questions on this site I still can't get their solutions to work.

Styles.xml

<resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarStyle">@style/ActionBar</item>
        <item name="android:windowActionBar">true</item>
    </style>

    <style name="ActionBar" parent="Widget.AppCompat.ActionBar.Solid">
        <item name="background">@color/light_blue_menu_bar</item>
    </style>
</resources>

colors.xml

<resources>
    ... 
    <color name="blue_semi_transparent_pressed">#80738ffe</color>
    <color name="light_blue_menu_bar">#87CEFA</color>
</resources>

manifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

However the ActionBar doesn't appear in of my views. What am I missing?

EDIT

The solution was to add to styles.xml

<item name="android:windowActionBar">true</item>

解决方案

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    <item name="actionBarStyle">@style/ActionBarStyle</item>
    <item name="android:windowActionBar">true</item>
</style>

<style name="ActionBarStyle" parent="Widget.AppCompat.ActionBar">
        <item name="background">@color/blue</item>
    <item name="android:background">@color/blue</item>
</style>

这篇关于Android的无法改变动作条的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆