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