Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: TextView.setTextAppearance() does not effect text size

Tags:

android

Running on my Samsung Galaxy Note, the below code logs 28.0 for each log statement. Am I doing something wrong?

label = new TextView(context);
Log.e("text size", "" + label.getTextSize());

label.setTextAppearance(context, android.R.attr.textAppearanceLarge);
Log.e("text size", "" + label.getTextSize());

label.setTextAppearance(context, android.R.attr.textAppearanceSmall);
Log.e("text size", "" + label.getTextSize());
like image 849
ab11 Avatar asked Dec 22 '11 18:12

ab11


1 Answers

Use the style class, not attr.

label.setTextAppearance(context, android.R.style.TextAppearance_Large);

This same point of confusion was reported here: TextView.setTextAppearance not working.

like image 116
ab11 Avatar answered Oct 17 '22 07:10

ab11