One would think this would increase text size by 10%:
view.setTextSize( (float) (view.getTextSize() * 1.1) );
But unfortunately, the get and set calls operate in different scales!
Check this out, on a Galaxy Nexus (phone):
float a = view.getTextSize(); // a = 44.0
view.setTextSize(a);
float b = view.getTextSize(); // b = 88.0
On a Nexus7 (tablet):
float a = view.getTextSize(); // a = 44.0
view.setTextSize(a);
float b = view.getTextSize(); // b = 58.6
The set call scales the number I give it by some arbitrary number.
I tried calling getScaleX() and getTextScaleX() to see if I could retrieve the scale value and account for it, but both of those calls always return 1.0
The two methods use different units. The value returned by
getTextSize()is in actual measured pixels whilesetTextSize()takes an argument in SPs, then measures it appropriately for the device. You need to useview.setTextSize(TypedValue.COMPLEX_UNIT_PX, a)to do what you’re looking for. The documentation has more info and other unit values.