首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在ActionBar上改变AppCompat颜色

如何在ActionBar上改变AppCompat颜色
EN

Stack Overflow用户
提问于 2015-03-29 21:13:41
回答 2查看 1K关注 0票数 0

我想知道如何更改AppCompat主题上的actionbar背景色。我的样式文件代码如下

价值观/风格

代码语言: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="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>

数值-V11

代码语言:javascript
复制
<resources>

    <!--
        Base application theme for API 11+. This theme completely replaces
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!-- API 11 theme customizations can go here. -->
    </style>

</resources>

Values-v14
<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>


</resources>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-29 21:31:59

您应该能够在colorPrimary中定义AppTheme

代码语言:javascript
复制
<style name="AppTheme" parent="AppBaseTheme">
    <item name="colorPrimary">#3f51b5</item>
</style>
票数 0
EN

Stack Overflow用户

发布于 2015-03-29 21:20:10

android如何做这个http://developer.android.com/training/basics/actionbar/styling.html

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>

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

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>

        <!-- Support library compatibility -->
        <item name="background">@drawable/actionbar_background</item>
    </style>
</resources>

然后将清单中的主题更改为上面所写的主题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29334907

复制
相关文章

相似问题

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