I would like to create an EditText which accepts only numbers, has a maximum of 4 numbers, and is never narrower than it would be if filled with 4 numbers (does not shrink
In my situation, I needed the view to be 6 digits wide. android:ems made the field too wide (since the M-character is wider than a digit).
I ended up using a transparent hint which dictates the minimum width of the field. The example below is six digits wide.
This solution is independent of font, letter spacing and other things which may vary. The textColorHint is a 0% opaque white color, so the hint should never be visible to the user.