gpt4 book ai didi

android - 在 TextView 上应用字体系列

转载 作者:行者123 更新时间:2023-11-29 15:57:44 24 4
gpt4 key购买 nike

我是 Android 新手。在我的应用程序中,我有多个 TextView,我想在 TextView 上应用不同的字体系列以及以下条件的数量:

1: TextView should never be extend i.e I don't want to create my custom Textview
2: I don't want to set the font on run time i.e First get the reference of textview in code then set programmitically by using the setType method.
3: I just want to do with the XML tag like "customeFontFamily" and for this tag i can provide different font family on different TextView.

我还读了this link但它显示第一个 android 默认字体系列。 500 毫秒后,它更改了我在 XML 中定义的字体系列。

如果您对此问题有任何帮助,我们将不胜感激!先感谢您!

最佳答案

您的要求:

1: I don't want to create a custom Textview by extending TextView

2: I don't want to set the font at run time.

3: I only want to use a custom XML attribute like "customFontFamily"

在这些要求下,您的问题没有解决方案。

Android SDK 中的所有 View 都没有代码来处理您定义的任何自定义 XML 属性。如果要使用自定义 XML 属性,则必须子类化 TextView。如果您不子类化 TextView,那么您别无选择,只能在运行时设置字体。仅此而已。

关于android - 在 TextView 上应用字体系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26912759/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com