Gaming.ingrs
Gaming.ingrs

Reputation: 281

Max. text size of TextView

We have ImageView as background and on ImageView some TextViews (something like specific ID card). Everything looks fine until user go to Android settings (not app) and enlarge font size (General, for every application). When he return to application, as text is now bigger, some TextViews do not match the ImageView. Is it possible to set max. text (font) size for TextView - working on API 24.

Tried with Auto-Sizing but it doesn't work for me as it is for API 26 and more.

android:autoSizeText=”uniform” 
autoSizeMaxTextSize=”25sp” 

Upvotes: 2

Views: 2988

Answers (1)

Alan Deep
Alan Deep

Reputation: 2105

Change sp to dp for TextView if you are using fixed ImageView size.

Never use sp inside a fixed sized component. There is a high chance that they might be cut when user enlarges the font in settings. Note that sp stands for scale-independent pixel, it means that it will grow depending on user's preferences. However, if you set it as dp, it will remain as it is.

Upvotes: 2

Related Questions