Reputation: 20100
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
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