Android - setTextSize()

By xngo on June 23, 2019

You can programmatically set the text size with the following code.

textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f);

Or, set the text size in res/values/dimensions.xml as follows.

<?xml version="1.0" encoding="utf-8"?>
    <dimen name="textsize">15sp</dimen>

Then, call the resource file like the following.


About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.