我正在使用以下代码将字体大小更改为中、高或小。getFontSize()将返回任何这些尺寸
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
holder.title.setTextAppearance(new AppController().getFontSize());
else
holder.title.setTextAppearance(mContext, new AppController().getFontSize());
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
java.lang.NoSuchMethodError: No virtual method setTextAppearance(I)V in class Landroid/widget/TextView; or its super classes (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar)
Run Code Online (Sandbox Code Playgroud)
为什么我会收到这样的错误?
TextView::setTextAppearance需要一个整数值,用于标识项目中的样式资源(如@android:style/TextAppearance.Material.Body1)。如果这是您的意图,请确保您的 getFontSize() 方法返回有效的 ID。
但是,我想,您实际上是在尝试设置字体大小,这应该使用setTextSize(float size)TextView 的方法来完成。
| 归档时间: |
|
| 查看次数: |
1908 次 |
| 最近记录: |