APPENDIX B: Setting the Font Size of a TextView Dynamically
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 ...
Get Android App Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.