Action bar字体的修改主要还是在xml文件中完成,对actionbar字体的修改主要思路如下:
- 根据application 的android:theme 属性找到他的style(方便起见,我们成为app_style)定义。
- 在style中找到name 为android:actionBarStyle 的item,找到android:actionBarStyle 对应的style(方便起见,我们成为actionbar_style)。
- 在actionbar_style中就可以看到name为android:titleTextStyle的item,再找到对应的style(我们称为titleText_style)
- 在titleText_style中可以发现里面有个定义了android:textSize的item,但是在这修该的话,不起作用,至于为什么,希望大家补充(PS:actionbar_style、titleText_style都是SDK中定义的,不知道是不是和这个有关)
- 既然上一个步骤型不同,但是我们可以在app_style所在的文件中定义一个actionbar style,然后在它的item下定义action bar的样式,具体的课参考下面的例子。
现在我们结合一个例子来说明(以android 4.4的settings应用为例):
- 在AndroidManifest文件中找到application中的属性
< application android:label = "@string/settings_label"android:icon = "@mipmap/ic_launcher_settings"android:taskAffinity = ""android:theme = "@style/Theme.Settings"android:hardwareAccelerated = "true"android:requiredForAllUsers = "true"android:supportsRtl = "true"android:name = ".Screenshot" >
- 找到android:theme对应的style,Theme.Settings。
< style name = "Theme.Settings" parent = "@android:style/Theme.Holo" >< item name = "@*android:preferenceHeaderPanelStyle" > @style/PreferenceHeaderPanelSinglePane </ item >< item name = "@*android:preferencePanelStyle" > @style/PreferencePanelSinglePane </ item >< item name