Indrek Kõue Indrek Kõue - 1 month ago 59
Android Question

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

<EditText
android:id="@+id/editText2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:maxLines="5"
android:lines="5">
</EditText>


User can input more than 5 lines, by pressing enter/next row key. How can I limit user input to fixed amount of rows with EditText?

Answer

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