标签:
标题样式是ActionBar样式的一部分,所以要先定义ActionBar的样式
<style name="AppTheme" parent="AppBaseTheme"> <item name="android:actionBarStyle">@style/CustomActionBar</item> </style>
然后在ActionBar的样式中通过android:titleTextStyle定义标题的样式
<style name="CustomActionBar" parent="@android:style/Widget.DeviceDefault.ActionBar"> <item name="android:titleTextStyle">@style/ActionBarTitle</item> </style> <style name="ActionBarTitle" parent="@android:style/TextAppearance.Holo.Large"> <item name="android:textColor">@android:color/holo_blue_bright</item> <item name="android:textSize">20sp</item> </style>
副标题样式同样是ActionBar样式的一部分,在ActionBar模式中通过android:subtitleTextStyle指定
<style name="CustomActionBar" parent="@android:style/Widget.DeviceDefault.ActionBar"> <item name="android:titleTextStyle">@style/ActionBarTitle</item> <item name="android:subtitleTextStyle">@style/ActionBarSubtitle</item> </style> <style name="ActionBarSubtitle" parent="@android:style/TextAppearance.Holo.Medium"> <item name="android:textColor">@android:color/holo_blue_light</item> <item name="android:textSize">16sp</item> </style>
菜单文字的自定义直接通过Activity的Theme指定,而不是通过ActionBar的样式
<style name="AppTheme" parent="AppBaseTheme"> <item name="android:actionBarStyle">@style/CustomActionBar</item> <item name="android:actionMenuTextAppearance">@style/ActionBarTitle</item> <item name="android:actionMenuTextColor">@android:color/holo_blue_light</item> </style> <style name="ActionBarMenu" parent="@android:style/TextAppearance.Holo.Large"> <item name="android:textColor">@android:color/holo_blue_light</item> <item name="android:textSize">20sp</item> </style>
有一点要注意,虽然通过android:actionMenuTextApperance指定的是TextApperance,但是文字的颜色要通过android:actionMenuTextColor单独指定
<style name="TextAppearance.Holo.Widget.ActionBar.Title" parent="TextAppearance.Holo.Medium"> <item name="android:textSize">@android:dimen/action_bar_title_text_size</item> </style> <style name="TextAppearance.Holo.Widget.ActionBar.Subtitle" parent="TextAppearance.Holo.Small"> <item name="android:textSize">@android:dimen/action_bar_subtitle_text_size</item> </style> <style name="TextAppearance.Holo.Widget.ActionBar.Menu" parent="TextAppearance.Holo.Small"> <item name="android:textSize">12sp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">?android:attr/actionMenuTextColor</item> <item name="android:textAllCaps">@android:bool/config_actionMenuItemAllCaps</item> </style>
标签:
原文地址:http://www.cnblogs.com/cocl/p/4512038.html