自定义Actionbar样式

来源:互联网 发布:排序算法有几种 编辑:程序博客网 时间:2024/05/20 03:44

备注: Theme.Holo.xxx主题下TabBar Tab项,仅能显示标题,无法显示指定的图片,可以改为“Theme.Black”或“Theme.Light"

以下内容为转载:

1)、在res/values/styles目录下,使用的是Theme.Sherlock.Light.DarkActionBar
          自定义的时候,只需要覆盖它的actionBarStyle即可:

<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar"></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/MyActionBarStyle</item></style>    <style name="MyActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">    <item name="background">@drawable/ab_custom_blue_holo_light</item></style>

当然,对应的字体颜色,图标颜色,菜单样式等等,都可能会变得不那么协调了,这需要多覆盖几项其它样式,比如字体颜色,图标的普通样式和按下样式等。  

    2)、在res/values-14/styles.xml下,只需要覆盖系统定义的即可:

<!--        Base application theme for API 14+. This theme completely replaces        AppBaseTheme from BOTH res/values/styles.xml and        res/values-v11/styles.xml on API 14+ devices.    -->    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">        <!-- API 14 theme customizations can go here. -->        <item name="android:actionBarStyle">@style/MyActionBarStyle</item>    </style>    <!-- Application theme. -->    <style name="AppTheme" parent="AppBaseTheme"></style>    <style name="MyActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">        <item name="android:background">@drawable/ab_custom_blue_holo_light</item>    </style>
 
0 0