How Android displays custom fonts in the idea Eclipse UI Editor Preview
-
The font to be displayed will be copied to. Android-sdk/platforms/android-[version]/data/fonts folder below
For example: Fontawesome-regular.ttf
-
Under Android-sdk/platforms/android-[version]/data/fonts, open fallback_fonts.xml
At the end of the add:
<family>
<FILESET>
< File>, " Span style= "Color:rgb (255,0,0);" >[the file name that is copied to the file, such as: Fontawesome-regular.ttf] </file>
</fileset>
</family
Then use the following style code in your custom view:
if (!isineditmode ()) { if (null == mfontawesome) { mfontawesome = typeface.createfromasset (Context.getAssets (), "Fonts/fontawesome-webfont.ttf"); } } else { try { /** * need to install fontawesome This SDK in Androidsdk, installation method See http://www.hianzuo.com */ &nBsp; mfontawesome = typeface.create (" Fontawesome ", typeface.normal); } catch (exception e) { throw new runtimeexception (e); } } settypeface (Mfontawesome);
This article is from the "hiandroid Studio" blog, be sure to keep this source http://hiandroidstudio.blog.51cto.com/5902332/1573867
How Android displays custom fonts in the idea Eclipse UI Editor Preview