Android中使用动态适配后设置TextView字体大小无效

Published on with 926 views

当项目中使用动态适配后,出现代码中使用setTextSize重新设置字体大小无效的情况。
经排查后发现,设置textSize后动态适配又重新将布局中的大小覆盖了代码中的大小。
因此在动态设置setTextSize前,只需重新设置TextView的layoutParam

RelativeLayout.LayoutParams layoutParams =(RelativeLayout.LayoutParams)textView.getLayoutParams();

textView.setLayoutParams(new RelativeLayout.LayoutParams(layoutParams));


标题:Android中使用动态适配后设置TextView字体大小无效
作者:yanjing
地址:https://yanjingtp.cn/articles/2023/03/28/1679987712541.html