Android Edittext not updating height is first letter is a new line. However, even if I press a letter and then press newlines, it starts to work.
Also, if I am typing a long line, it is working fine as well.
How can I fix it?
Android Edittext not updating height is first letter is a new line. However, even if I press a letter and then press newlines, it starts to work.
Also, if I am typing a long line, it is working fine as well.
How can I fix it?
2
Answers
Sounds like an edge case, I’ll just assume that your app is in the 90% of apps where a new line at the start of the EditText is not something you want anyways. In that case you can use callbacks like beforeTextChanged:
https://developer.android.com/reference/android/text/TextWatcher#beforeTextChanged(java.lang.CharSequence,%20int,%20int,%20int)
To either remove/ignore a newline at the start
or
replace one n with nn (2 newlines, which should increase the height, but not 100% sure)
As Per Your Question you have to set a EditText As per Your Situation.In Normal Edittext code is as below.
If you want to set a height of you edittext is long then you want to code as below
you can change the layout height as per your Choice