I know about the similar max length method for EditText that looks like this
editText.maxLength = "21"
But the problem is that this type of method isn't effective in my case. I have an EditText that has special dimension, so my goal is to not allow symbols to pass edittext's border. I nedd something that maximizes length of edittext more by dimension, than by symbols. Symbols have a different size, so maybe maxLength should be based on size of "M" symbol.
Works perfectly fine:
But when symbols bigger appear this happens:

