Android 全域使用第三方字型

來源:互聯網
上載者:User

標籤:分享   使用   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 全域使用第三方字型

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.