EditText maxLines not working – user can still input more lines than set

<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 you have the attribute “inputType” set. It doesn’t work without this line.

android:inputType="text"

Leave a Comment