標籤:
這個自訂字型其實和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">
Android自訂標題列字型