低版本系统兼容的ActionBar(七)自定义Actionbar标题栏字体

这个自定义字体其实和ActionBar有关,但之前写AtionBar的时候没考虑到修改字体样式,今天看到一篇专门写这个的文章就贴上使用方式。╮(╯▽╰)╭,不得不说Actionbar的那个样式真是让人头疼,明明是可以用图形界面来指定的嘛。

 

res/values/styles.xml文件中加入下列代码

<style name="MyActivityTheme" parent="android:Theme.Light" >
      <item name="android:windowTitleBackgroundStyle">@style/windowTitleBackgroundStyle</item>
      <item name="android:windowTitleStyle">@style/windowTitleStyle</item>
      <!-- Window Header Height -->
      <item name="android:windowTitleSize">54dp</item>
  </style>
  
  <!-- Preference Settings Window Title -->
  <style name="windowTitleBackgroundStyle">
      <item name="android:background">#CCE8CF</item>
      </style>
      
      <style name="windowTitleStyle">
      <item name="android:textColor">#FF0000</item>
      <item name="android:paddingLeft">25dp</item>
      <item name="android:textSize">20sp</item>
  </style>

接下来给Activity使用这个主题就行啦。

<activity
    android:name="com.example.stylewindowtitle.MainActivity"
    android:label="@string/app_name"
    android:theme="@style/MyActivityTheme">

 

posted @ 2015-01-11 19:14  developer_Kale  阅读(368)  评论(0编辑  收藏  举报
网站流量统计工具