Android ActionBar背景設置漸變色

styles.xml

<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. -->
        <item name="actionBarStyle">@style/ActionBarStyle</item>
    </style>

    <style name="ActionBarStyle" parent="Widget.AppCompat.ActionBar">
        <item name="background">@drawable/bg_action_bar</item>
        <item name="titleTextStyle">@style/ActionBarTitleStyle</item>
    </style>

    <style name="ActionBarTitleStyle">
        <item name="android:textSize">20sp</item>
        <item name="android:textColor">@android:color/white</item>
    </style>

</resources>
bg_action_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >


    <!-- 線性漸變 -->
    <gradient
        android:angle="45"
        android:centerColor="@android:color/white"
        android:centerX="0"
        android:centerY="0"
        android:endColor="@android:color/black"
        android:gradientRadius="90"
        android:startColor="@android:color/white"
        android:type="linear"
        android:useLevel="true" />


</shape>

http://blog.csdn.net/xy_nyle/article/details/18970211

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章