O'Reilly logo

Android App Development by Franceschi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

APPENDIX B: Setting the Font Size of a TextView Dynamically

Chapter opener image: © Fon_nongkran/Shutterstock

Sizing the font inside a TextView is one issue that arises often when building an app. Since the app will run on many devices with various screen sizes, it could look awkward on some devices if we use the same font size for all the devices. There are many ways to set the size of the font inside a TextView so that the text fits well. We explore how to set it so that the text fits in one line and the font size is maximal. We assume that there is no padding inside the TextView.

We build a utility class, DynamicSizing, that includes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required