<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?
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.
or programmatically
Another way to limit your
EditText
to one line is the following:Note that after applying this transformation method, the enter key creates spaces when pressed. That still satisfies TS' question.
this is one approach. Might help someone.
Simplest solution:
...
You can limit your text according to your no of lines i say around 37 alphabets in one line