Skip to content

Instantly share code, notes, and snippets.

@AvatarQing
Created February 10, 2014 03:12
Show Gist options
  • Save AvatarQing/8909756 to your computer and use it in GitHub Desktop.
Save AvatarQing/8909756 to your computer and use it in GitHub Desktop.
supprot v7 AppCompat 自定义ActionBar样式
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Application theme. -->
<style name="AppThemeForMobileSafe" parent="AppBaseThemeForMobileSafe">
<item name="android:actionBarStyle">@style/MobilseSafeActionBarStyle</item>
</style>
<style name="MobilseSafeActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<!-- 自定义ActionBar的背景色 -->
<item name="android:background">@drawable/action_bar_bg</item>
<!-- ActionBar标题文字样式 -->
<item name="android:titleTextStyle">@style/MobileSafeActionBarTitleStyle</item>
<!-- ActionBar副标题文字样式 -->
<item name="android:subtitleTextStyle">@style/MobileSafeActionBarSubtitleStyle</item>
</style>
</resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. -->
<style name="AppBaseThemeForMobileSafe" parent="@style/Theme.AppCompat.Light"></style>
<!-- Application theme. -->
<style name="AppThemeForMobileSafe" parent="AppBaseThemeForMobileSafe">
<item name="actionBarStyle">@style/MobilseSafeActionBarStyle</item>
</style>
<style name="MobilseSafeActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- 自定义ActionBar的背景色 -->
<item name="background">@drawable/action_bar_bg</item>
<!-- ActionBar标题文字样式 -->
<item name="titleTextStyle">@style/MobileSafeActionBarTitleStyle</item>
<!-- ActionBar副标题文字样式 -->
<item name="subtitleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle</item>
</style>
<!-- 自定义的ActionBar标题文字样式 -->
<style name="MobileSafeActionBarTitleStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/actionbar_main_title</item>
</style>
<!-- 自定义的ActionBar副标题文字样式 -->
<style name="MobileSafeActionBarSubtitleStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">@color/actionbar_main_subtitle</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment