How can I change the style of action bar API 15

前端 未结 2 789
迷失自我
迷失自我 2020-12-22 06:25

I want to change the style of my Action bar so I want to change the color of line under the action bar from Blue to Orange , how can I do that?

相关标签:
2条回答
  • 2020-12-22 06:29

    If you want change it by code, you could try this:

    getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.myninepatch));
    
    0 讨论(0)
  • 2020-12-22 06:36

    There is a good tutorial here

    Create a new style with your custom drawable

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <!-- the theme applied to the application or activity -->
        <style name="Theme.MyStyle" parent="@android:style/Theme.Holo">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
            <!-- other activity and action bar styles here -->
        </style>
    
        <!-- style for the action bar backgrounds -->
        <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
            <item name="android:background">@drawable/ab_background</item>
            <item name="android:backgroundStacked">@drawable/ab_background</item>
            <item name="android:backgroundSplit">@drawable/ab_split_background</item>
        </style>
    </resources>
    

    then in AndroidManifest.xml add the custom style

    <application
            android:debuggable="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
    
            android:theme="@style/Theme.MyStyle"
            >
       <activity ...>
       <activity .../>
       ...
    
    </application>
    
    0 讨论(0)
提交回复
热议问题