28

When specifying text size on Android, the suggested the best practice is to use sp font units instead of dp, since with sp the text will increase/decrease in size according to the user's display preferences. For example, on my device I can go to

Settings -> Display -> Font

and choose a preference: small, normal, large, huge (these seem to vary across devices though).

Does anyone know a way to preview the effect of this preference in Android Studio's layout preview? It would be easier than having to deploy to a device/emulator in order to test. I can't see an option for this, but maybe I'm missing it.

Related: is there a standard multiplier for what the largest ("huge") font preference equals to? Or, can this even vary across devices? If there's no upper bound to how large the text could be, the first part of my question is probably moot.

Sakib Arifin
  • 255
  • 2
  • 13
dfinn
  • 968
  • 1
  • 10
  • 16
  • Related: https://stackoverflow.com/questions/14102749/how-to-display-graphical-layout-previews-for-different-user-selected-display-fon?rq=1 – David Rawson Jul 06 '17 at 22:44

2 Answers2

11

As of about May 2020, This can now be done via the Layout Validation feature of Android Studio 4.0. This allows you to view different Font Sizes, devices and even see your layouts from the perspective of someone with color blindness.

enter image description here

gMale
  • 17,147
  • 17
  • 91
  • 116
  • I use Android Studio 4.0.1 on Linux and this feature doesn't seem to be available yet - can anyone else confirm? – pallgeuer Sep 28 '20 at 13:45
  • 3
    @pallgeuer it's not default preview, you can find right one in View -> Tool Windows -> Layout validation – CeH9 Nov 01 '20 at 19:29
1

No, there is no such way to preview the font scaling in the android studio as of now. but you can check out the material design for text scaling at < https://material.io/design/typography/the-type-system.html#type-scale > here you will some idea of how your text looks in runtime

brew
  • 91
  • 2
  • 11