首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用Actionbar的默认背景并添加自定义背景

禁用Actionbar的默认背景并添加自定义背景
EN

Stack Overflow用户
提问于 2014-12-05 11:24:28
回答 1查看 54关注 0票数 0

我试图添加自定义背景到AppCompat操作栏。这是我的风格

代码语言:javascript
复制
<!--
    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">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <!--
        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>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:background">@drawable/top_bar_bg</item>
</style>

我使用AppTheme作为我的主题。它仍然显示默认的黑暗背景。我在这里错过了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-05 11:34:02

在res/value/styes.xml中:

代码语言: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="actionBarStyle">@style/MyActionBar</item>
        </style>

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

在res/value中-v11/styes.xml:

代码语言: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>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>
    </style>
</resources>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27314844

复制
相关文章

相似问题

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