首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Android中设置Action的背景色

在Android中设置Action的背景色
EN

Stack Overflow用户
提问于 2014-04-17 13:35:55
回答 3查看 631关注 0票数 0

你好,我是机器人公司的诺布。

我使用appcompat支持库使我的应用程序向后兼容。在这里,动作栏的颜色是Light,默认情况下,我想将背景色更改为我的自定义颜色。

知道怎么做吗??

styles.xml

代码语言:javascript
复制
<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-04-17 13:49:12

这解决了我的问题。谢谢卓哈拉

代码语言:javascript
复制
ActionBar mActionBar = getActionBar();
mActionBar.setBackgroundDrawable(new ColorDrawable("COLOR"));
票数 1
EN

Stack Overflow用户

发布于 2014-04-17 13:46:03

您可以尝试使用来自正式文件的方法。我认为它有明确的例子来做这件事。

票数 0
EN

Stack Overflow用户

发布于 2014-04-17 13:52:04

你的风格可能是这样的

参考资料:- https://developer.android.com/training/basics/actionbar/styling.html

代码语言:javascript
复制
  <style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light">

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
  </style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">

    <!-- Support library compatibility -->
    <item name="background">@drawable/actionbar_background</item>
</style>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23134651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档