ab11
ab11

Reputation: 20100

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

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());

Upvotes: 16

Views: 18985

Answers (1)

ab11
ab11

Reputation: 20100

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.

Upvotes: 72

Related Questions