Question: I've already set the maxLength attribute for an EditText widget in the xml layout file, and it does limit the display of characters.

But it still allows the user to press more letters on the keyboard, and backspacing deletes these extra presses rather than the last letter on the display.

I believe this is not how it's supposed to be. Pressing keys after the limit has been reached should stop accepting more input even if it is not displayed. 

Any fix on this?

**Update**

Based on the answer below, for multiline EditText, add the textMultiLine attribute too.

```
android:inputType="textFilter|textMultiLine"

```

Answer: 
1. Disable auto-suggestions(`android:inputType="textFilter"` or `textNoSuggestions`):
2. Set maxLength

```
<EditText
   android:id="@+id/editText"
   android:inputType="textFilter"
   android:maxLength="8"
   android:layout_width="match_parent"
   android:layout_height="wrap_content" />

```

I hope, it helps
You can use **[InputFilter](http://developer.android.com/intl/es/reference/android/text/InputFilter.html)**

> 
> InputFilters can be attached to Editables to constrain the changes
>  that can be made to them.
> 
> 
> 

**Xml**

```
    <EditText
   android:id="@+id/edit_Text"
   android:layout_width="match_parent"
   android:layout_height="wrap_content" />

```

**Java Class** 

```
int maxLengthofYourEditText = 5;    // Set Your Limit 
edit_TextObj.setFilters(new InputFilter[] {new InputFilter.LengthFilter(maxLengthofYourEditText)});

```