【发布时间】:2018-06-25 04:21:33
【问题描述】:
我已经为 textView 设置了一些布局。
android:fontFamily="@font/cookie_regular"
但是当我需要 Java 代码时,我希望有更多设置选项来清除/设置默认字体。 你有什么建议吗?
【问题讨论】:
-
尝试使用 setTypeface
标签: android fonts font-family
我已经为 textView 设置了一些布局。
android:fontFamily="@font/cookie_regular"
但是当我需要 Java 代码时,我希望有更多设置选项来清除/设置默认字体。 你有什么建议吗?
【问题讨论】:
标签: android fonts font-family
当您想将某些文本视图更改为不同的字体时调用此方法。
public void change_font(){
//if or switch statement may be needed or not.
Typeface custom_font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/THE_FONT_I_HAVE_CREATED_OR_DOWNLOADED.ttf");
//FYI font is a file you can create in your res folder.
myTEXTVIEW.setTypeface(custom_font);
}
最后是关于可下载字体的更多信息 https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
【讨论】: