Home > Software design >  When should we use android:ems over android:textSize when specific font size for EditText?
When should we use android:ems over android:textSize when specific font size for EditText?

Time:10-04

There are 2 ways to specific text size in EditText

  • android:textSize
  • android:ems

Most of the time, I am using android:textSize in sp unit

I was wondering, in what situation, we should use android:ems ( I do understand the meaning of ems from What is meant by Ems? (Android TextView) )

CodePudding user response:

one em in a 16-point typeface is 16 points

em is more predefined while textSize using sp is specific. It depends on your use case.

Sidenote: You can also set an EditText's text size by using textAppearance.

CodePudding user response:

You should very rarely use ems. Ems doesn't scale. It means your text is always a fixed height. This makes your app difficult to read for people who have vision problems. You should only use it if your app will absolutely not work correctly with scaled text and you don't care how that effects the disabled.

  • Related