In Android, how to create EditText of fixed width?

后端 未结 10 484
醉酒成梦
醉酒成梦 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

    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"
    

提交回复
热议问题