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
You can also try using. . .
android:ems="4"
android:maxEms="4"
android:layout_width="wrap_content"
. . . this should insure the tightest fit possibly allowed by the default android edittext style
For additional control with the padding on both left and right you can use
android:background="#ffffff"
android:paddingLeft="0dp"
android:paddingRight="0dp"