Limiting EditText Lines (LEL)

Hi guys, I would like to share a little experience after creating a UI form for Android. I found something strange, such as the user being able to press enter or in other words, the user being able to input several lines like a paragraph, even though I have set maxLines() to 1.

Solution

<EditText 
    android:id= "@+id/edit_text" 
    android:layout_width= "match_parent" 
    android:layout_height= "wrap_content" 
    android:inputType= "text" 
    android:maxLines= "1"  
/>

You just need to make sure that you have set the "inputType" attribute, as limiting the number of lines won't work without it.

Post a Comment

Previous Next

نموذج الاتصال