I have noticed that Telegram has a smooth animation in their chat EditText when a new line is inserted / started.
Below I have two GIFs. The first is Telegram, the second is my app.
How can you achieve such an animation effect?
I tried to google it, but I didn’t find anything. I know Telegram is open source, I tried to find out from their GitHub, but I couldn’t find what gives the EditText this smooth animation.
2
Answers
It is very easy. I too added it in my chat app and it works like a charm. In your root layout, add this line:
This will animate all the changes happening in the layout.
Edit
If that does not help, you can do this.
You can call this method in
onKeyListener
and when the new line key is pressed, this code can be called.Edit
Sometimes, while entering the text, it goes to new line. For animation this, we can do this:
And for the backspace key, you can do this:
If the above answer does not work, you can use this:
Where
defEditTextHeight
is the default height of the edit text fetched like this:Hope It helps 🙂