我使用以下代码
TextView as;
as=(TextView)fragmentView.findViewById(R.id.e1_name);
Typeface font = Typeface.createFromAsset(getActivity().getAssets(),"fonts/wt071.ttf ");
as.setTypeface(font);
结果错误
01-13 13:45:32.587 22738-22738/cytech.example.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: cytech.example.app, PID: 22738
java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.<init>(Typeface.java:175)
at android.graphics.Typeface.createFromAsset(Typeface.java:149)
at cytech.example.app.e.fg_e1.onCreateView(fg_e1.java:58)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Android中不支持TTF吗?
我尝试过很多中文TTF而且没有用。
有什么方法可以解决 或者我在哪里可以找到支持的列表
答案 0 :(得分:2)
试试这个.. .ttf
后"fonts/wt071.ttf "
删除该内容,然后尝试
Typeface font = Typeface.createFromAsset(getActivity().getAssets(),"fonts/wt071.ttf");
as.setTypeface(font);