gpt4 book ai didi

android - 一次将所有布局设置为 setTypeface ...android

转载 作者:行者123 更新时间:2023-11-29 16:02:11 25 4
gpt4 key购买 nike

是否可以同时为所有 View (包括 ListView )设置字体,而不是为每个 View 都这样做。谢谢

最佳答案

您可以使用以下方法为布局设置字体

public void setFont(ViewGroup group, Typeface font) {
int count = group.getChildCount();
View v;
for (int i = 0; i < count; i++) {
v = group.getChildAt(i);
if (v instanceof TextView || v instanceof EditText || v instanceof Button) {
((TextView) v).setTypeface(font);
} else if (v instanceof ViewGroup)
setFont((ViewGroup) v, font);
}
}

关于android - 一次将所有布局设置为 setTypeface ...android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23268611/

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