標籤:分享 使用 item cti 介面 images blank androi mon
給APP全域設定字型主要分為兩個方面來介紹
一、給原生介面設定第三方字型
1、準備工作-下載第三方字型:傳送門
將檔案放入工程assets目錄下。(一般個人習慣單獨命名一個檔案夾放字型檔,也可直接放入根目錄,但記得改引用路徑)
2、代碼實現
a、自訂application,將第三方的字型,替換當前系統預設字型
b、定義style
<style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="android:typeface">monospace</item></style>
c、設定在manifests檔案中設定application
<application android:name=".application.WeexApplication" android:allowBackup="true" android:icon="@drawable/app_icon" android:label="@string/app_name" android:roundIcon="@drawable/app_icon" android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar">
註:需要注意name是自訂application路徑,theme是自訂風格
二、給網頁設定第三方字型
1、載入本地HTML頁面使用本地字型
這種情況比較容易,只需要在本地檔案上添加JS代碼即可
<style> @font-face { font-family: ‘MyCustomFont‘; src: url(‘file:///android_asset/fonts/textstyle.ttf‘); } p{ font-family:"MyCustomFont"; font-size: x-large; } body { margin: 0; } </style>
<body style=‘font-family:MyCustomFont;‘>
2、載入網路HTML頁面使用本地字型
將網路頁面字型轉換可以參考如下網址:http://blog.csdn.net/aiynmimi/article/details/52777965
Android 全域使用第三方字型