Solutions to Android custom Fonts

Source: Internet
Author: User

About Android custom Fonts
I used the following statement to customize the font of the content:

Textview TV = (textview) findviewbyid (R. Id. maintitle );
// Change the font
Typeface face = typeface. createfromasset (getassets (), "fonts/hyyy. TTF ");
TV. settypeface (FACE );

Import the font file hyyy. TTF in assets/front. The size is 3.37 MB.

But the program does not know why it cannot run.
The following figure shows the logcat:

04-01 02:33:21. 338: E/androidruntime (323): Fatal exception: Main
02:33:21 04-01. 338: E/androidruntime (323): Java. lang. runtimeexception: unable to start activity componentinfo {Mars. product/Mars. product. mainactivity}: Java. lang. runtimeexception: Native typeface cannot be made
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2663)
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. activitythread. handlelaunchactivity (activitythread. Java: 2679)
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. activitythread. Access $2300 (activitythread. Java: 125)
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. activitythread $ H. handlemessage (activitythread. Java: 2033)
04-01 02:33:21. 338: E/androidruntime (323): at Android. OS. handler. dispatchmessage (handler. Java: 99)
04-01 02:33:21. 338: E/androidruntime (323): at Android. OS. Looper. Loop (Looper. Java: 123)
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. activitythread. Main (activitythread. Java: 4627)
04-01 02:33:21. 338: E/androidruntime (323): At java. Lang. Reflect. method. invokenative (native method)
04-01 02:33:21. 338: E/androidruntime (323): At java. Lang. Reflect. method. Invoke (method. Java: 521)
04-01 02:33:21. 338: E/androidruntime (323): At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
04-01 02:33:21. 338: E/androidruntime (323): At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
04-01 02:33:21. 338: E/androidruntime (323): At Dalvik. system. nativestart. Main (native method)
04-01 02:33:21. 338: E/androidruntime (323): caused by: Java. Lang. runtimeexception: Native typeface cannot be made
04-01 02:33:21. 338: E/androidruntime (323): at Android. Graphics. typeface. <init> (typeface. Java: 147)
04-01 02:33:21. 338: E/androidruntime (323): at Android. Graphics. typeface. createfromasset (typeface. Java: 121)
04-01 02:33:21. 338: E/androidruntime (323): at Mars. Product. mainactivity. oncreate (mainactivity. Java: 42)
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1047)
04-01 02:33:21. 338: E/androidruntime (323): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2627)
04-01 02:33:21. 338: E/androidruntime (323):... 11 more


How can I modify it?

------ Solution --------------------------------------------------------
There is no problem with the Code. 3 m + is too big. Use fontcreator to crop it, several hundred K.
I guess this is probably because native typeface cannot be made.
------ Solution --------------------------------------------------------
The file format is defined as MP3 or zip, so there is no size limit, so it is still used in use, you try

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.