deano2390/FlowTextView

Add support for sp units

Closed this issue · 1 comments

It would be great if you could set the size in sp units to adapt to all kind of screen sizes/density

Since I'm not sure if it's possible to implement this, I'll post the solution I found: http://stackoverflow.com/questions/2069810/how-to-assign-text-size-in-sp-value-using-java-code

So, to get sp font size do the following:

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
pixelSize = (int)scaledPixelSize * dm.scaledDensity;

Where scaledPixelSize is the sp size you want. It works well.
Thanks a lot for this library!