To make an EditText have a fixed length you need to add android: maxLength in <EditText> tag.
⛏️ android:MaxLength : Set an input filter to constrain the text length to the specified number. [integer]
Example
<EditText
android:id="@+id/editText1"
android:maxLength="20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:ems="10" >
The EditText will only allow 20 characters, if you try entering any further it won't get added up.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!