android添加背景到动作栏

时间:2014-02-10 13:41:13

标签: android

我正在使用支持库添加操作栏。

res / values / styles中的

   <?xml version="1.0" encoding="utf-8"?>
    <resources>

        <style name="Theme" parent="android:Theme"></style>

        <style name="Theme.Transparent">
            <item name="android:windowIsTranslucent">true</item>
            <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
            <item name="android:windowBackground">@drawable/transparent_background</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:colorForeground">#fff</item>
        </style>
    <!-- the theme applied to the application or activity -->
        <style name="CustomActionBarTheme"
               parent="@style/Theme.AppCompat">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
            <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
            <item name="android:actionMenuTextColor">@color/actionbar_text</item>

            <!-- Support library compatibility -->
            <item name="actionBarStyle">@style/MyActionBar</item>
            <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
            <item name="actionMenuTextColor">@color/actionbar_text</item>
        </style>

        <!-- ActionBar styles -->
        <style name="MyActionBar"
               parent="@style/Widget.AppCompat.ActionBar">
            <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>

            <!-- Support library compatibility -->
            <item name="titleTextStyle">@style/MyActionBarTitleText</item>
        </style>

        <!-- ActionBar title text -->
        <style name="MyActionBarTitleText"
               parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
            <item name="android:textColor">@color/actionbar_text</item>
            <!-- The textColor property is backward compatible with the Support Library -->
        </style>

        <!-- ActionBar tabs text -->
        <style name="MyActionBarTabText"
               parent="@style/Widget.AppCompat.ActionBar.TabText">
            <item name="android:textColor">@color/actionbar_text</item>
            <!-- The textColor property is backward compatible with the Support Library -->
        </style>

</resources>

然后当我添加此

application android:theme="@style/CustomActionBarTheme" 

到mainfest,应用程序开始了。如果我删除它,应用程序运行完美

帮助pelase

1 个答案:

答案 0 :(得分:0)

尝试使用:Action bar stylle generator。它很简单,适用于默认,ActionBarSherlock,Holoeverywhere主题。