Android Global use of third-party fonts

Source: Internet
Author: User
Tags custom name

To the app global font mainly divided into two aspects to introduce

First, to set a third-party font to the native interface

1. Getting ready to work-download third-party fonts: Portal

Put the file in the Project assets directory. (General personal custom name a file folder to put the font file, you can also directly into the root directory, but remember to change the reference path)

    

2. Code implementation

A, custom application, replace the font of the third party with the current system default font

    

B. Define Style

    

<style name= "Apptheme.noactionbar" >        <item name= "Windowactionbar" >false</item>        <item name= "Windownotitle" >true</item>        <item name= "Android:typeface" > Monospace</item></style>

C, set the settings in the manifests file 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" >

Note: Note that name is a custom application path and theme is a custom style

Second, to set a third-party font page

1. Loading local HTML pages using local fonts

This is easy, just add the JS code to the local file to

    <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. Load the network HTML page using local fonts

The Web page font conversion can be referred to the following URL: http://blog.csdn.net/aiynmimi/article/details/52777965

Android Global use of third-party fonts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.