Disable Enter in editText android

Because of different Android versions, the best practice is to include these parameters at the same time:

         android:maxLines="1"
         android:lines="1"
         android:singleLine="true"

If you don't, it will not work correctly on some devices.


android:maxLines="1" allows the text to be multiline but limits the height of edittext to display a single line.

If you want to disable the enter (new line) key, set the input type to text

    android:inputType="text"