很多时候,系统的主题并不适用,app想要自己喜欢的主题,这个时候需要自定义一个主题。
这里就简单讲述一下自定义主题的步骤。(以DarkActionBar修改title大小为例)
一、相关文件:
主题相关的文件:
AndroidManifest.xml和styles.xml文件
在AndroidManifest中需要引用自定义的主题给app使用:
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/MyTheme" >最后一样引用自定义的主题:MyTheme。
这个MyTheme,定义在styles.xml中。
这个sytyles.xml在目录:res/values/下面。
二、如何写自定应的styles.xml
认识一个东西,一定是先直观看上去,有了第一直观认知;再次进行详细的分析就能认识一个事物。
所以这里先看一下我们的demo中的styles.xml。(自定义:修改DarkActionBar的title字体大小)
<resources> <style name="MyTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar" > <item name="android:actionBarStyle">@style/Inverse</item> </style> <style name="Inverse" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse&#