In Android, how to create EditText of fixed width?

后端 未结 10 466
醉酒成梦
醉酒成梦 2020-12-04 17:52

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

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 18:10

    One rarely-used (AFAIK) attribute of an EditText that you can use is:

    android:ems="4"

    This makes the EditText exactly 4 ems wide. An em width is the width of the widest (M) character in the selected font.

提交回复
热议问题