【问题标题】:How to clear fontFamily after setup in XML在 XML 中设置后如何清除 fontFamily
【发布时间】:2018-06-25 04:21:33
【问题描述】:

我已经为 textView 设置了一些布局。

android:fontFamily="@font/cookie_regular"

但是当我需要 Java 代码时,我希望有更多设置选项来清除/设置默认字体。 你有什么建议吗?

【问题讨论】:

标签: android fonts font-family


【解决方案1】:

当您想将某些文本视图更改为不同的字体时调用此方法。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-29
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 2018-09-21
    相关资源
    最近更新 更多