(android)ActionBar主题样式,能兼容2.1以上

来自官方的介绍http://developer.android.com/intl/zh-cn/training/basics/actionbar/styling.html

本文章归属于小黑_mo所有,转载请说明出来http://my.oschina.net/moziqi/

<a href="http://stackexchange.com/users/5781182">

<img src="http://stackexchange.com/users/flair/5781182.png" width="208" height="58" alt="profile for handler_mo on Stack Exchange, a network of free, community-driven Q&amp;A sites" title="profile for handler_mo on Stack Exchange, a network of free, community-driven Q&amp;A sites">

</a>

themes.xml

<?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>
        <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
        <!-- Support library compatibility-->
        <!--修改背景-->
        <item name="background">@drawable/actionbar_background</item>
        <!--修改actionbar的字体颜色-->
        <item name="titleTextStyle">@style/MyActionBarTitleText</item>
    </style>


    <!-- ActionBar title text -->
    <style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">#FFFFFF</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">#FFFFFF</item>
        <!-- The textColor property is backward compatible with the Support Library -->
    </style>
</resources>

我喜欢的colors.xml

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

    <color name="button_ok">#1E88E5</color>
    <color name="white">#FFFFFF</color>
    <color name="green">#0aa770</color>
</resources>


你可能感兴趣的:((android)ActionBar主题样式,能兼容2.1以上)