Search code examples
androidenter

How to limit returns in a multiple line EditText?


I put a multiline EditText in my application. The problem is that if the user presses enter, the EditText often collides with the icons in my application. I want to avoid that.

I wanted to know how to make it so that the user can only press enter 5 times and no more?


Solution

  • To restrict the height of an EditText, you can use the maxLines attribute

    <EditText
    ...
    android:maxLines="5"
    ...
    />