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
A little hackish, but you can put your EditText inside a FrameLayout alongside with another TextView with text="0000" and visibility=invisible.FrameLayout Should have width=wrap_content and your EditText will have width=match_parent.
That should make it the right width always.
The advantage of this is, it's 100% xml-side, no code involved.