Implementation of setTextSize(float size)
public void setTextSize(float size) { setTextSize(TypedValue.COMPLEX_UNIT_SP, size); }
In your case, what happens is that you scale the value specified in setTextSize , since getDimension returns the size times the metric. Try
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.defaultTextSize));
source share