How do I prevent an EditText from resizing itself when the user is typing?
For EditText use
android:layout_width="0dp" - not required but preferred.
android:layout_weight="1"
And for Button dont specify android:layout_weight
What I do is in the onCreate for the activity, measure the EditText first then apply its maxWidth.
You can do so using code similar to the following:
EditText someedittext = (EditText)findViewById(R.id.sometextview);
someedittext.setMaxWidth(someedittext.getWidth());
Give EditText
a maxWidth
. That should stop it from resizing beyond the width you provided. Also, if you want it to be contained within 1 line set the maxLines
setting to 1 too.
You need to add android:imeOptions to prevent this behavior.