gpt4 book ai didi

android - 在android应用程序中设置自定义字体

转载 作者:太空宇宙 更新时间:2023-11-03 12:00:00 27 4
gpt4 key购买 nike

是否可以一次为整个 Android 应用程序设置自定义字体。我的意思是我不想在每个 Activity 中为每个 TextView 使用 setTypeFace。不仅是 TextView ,还有所有可能的文本。

最佳答案

只需制作您自己的 TextView:

public class CustomFontTextView extends TextView {

// make every constructor call init();

private void init() {
setTypeFace(...);
}

}

在 xml 中:

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.yourcompany.yourproject.views.CustomFontTextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Test"/>
</LinearLayout>

关于android - 在android应用程序中设置自定义字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11842924/

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