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

Solution 1:

<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"

Solution 2:

The attribute maxLines corresponds to the maximum height of the EditText, it controls the outer boundaries and not inner text lines.

Solution 3:

This does not solve the general issue of limiting to n lines. If you want to limit your EditText to take just 1 line of text, this can be very easy.
You can set this in the xml file.

android:singleLine="true"

or programmatically

editText.setSingleLine(true);