如果我在我的xml中使用android:textSize="?android:attr/textAppearanceLarge",我的应用程序就会崩溃。我不想提供硬编码的文本大小,因为我必须为不同的屏幕大小创建xml,或者我必须在运行时管理文本大小。这是Log.e输出-06-2611:46:27.439:E/AndroidRuntime(1731):atandroid.view.LayoutInflater.createView(LayoutInflater.java:620)06-2611:46:27.439:E/AndroidRuntime(1731):atcom.android.
styles.xml文件中有3种样式:22sp18sp14sp?textColorSecondaryTextAppearance.Small有不同的颜色,但TextAppearance.Large和TextAppearance.Medium应该有相同的颜色。如果在TextView中设置这些样式:android:textAppearance="?android:attr/textAppearanceLarge"和android:textAppearance="?android:attr/textAppearanceMedium"它们的颜色略有不同。为什么以及在哪里可以找到这些颜色?
我现在正在修改自定义首选项,我想使用TextView为其添加标签。但是我似乎找不到使用setTextView()将文本大小指定为“大”的方法我在这里错过了什么? 最佳答案 TextViewtitle=newTextView(context);title.setTextAppearance(context,android.R.attr.textAppearanceLarge);或者试试setTextAppearance(context,android.R.style.TextAppearance_Large);使用上面的代码试试