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.
Click on the font or emoji name to get a preview. Use the search to see if a font or emoji is available, and the form below to request it if it's not.
A font is often measured in pt (points). Points dictate the height of the lettering. There are approximately 72 (72.272) points in one inch or 2.54 cm. For example, the font size 72 would be about one inch tall, and 36 would be about a half of an inch.
Go to File -> Settings, a new setting dialogue box will appear. Then go to Editor -> General. Now mark the checkbox Change font size with Ctrl + Mouse wheel and click on Apply button. Now to change your editor font size, you just have to press and hold Ctrl and rotate the Mouse wheel.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With