Edittext Maxlines Not Working - User Can Still Input More Lines Than Set

EditText maxLines not working - user can still input more lines than set

The attribute maxLines corresponds to the maximum height of the EditText, it controls the outer boundaries and not inner text lines.

Android bug with Edittext MaxLines

For now you should use inputType="text" with maxLines="1" for a single line.

Discussion on SO why it's deprecated:
Is the xml attribute singleLine deprecated or not in Android?

Google issue:
https://code.google.com/p/android/issues/detail?id=221762

maxLines attribute doesn't work

Try this set android:imeOptions="actionNext" and also set android:inputType="text"
to Your EditText

Sample Code

<android.support.design.widget.TextInputLayout
android:id="@+id/tplUserName"
style="@style/EditText_Style_1"
app:hintTextAppearance="@style/TextLabel">

<EditText
android:id="@+id/etUserName"
style="@style/StandardEditTextStyle"
android:imeOptions="actionNext"
android:inputType="text"
android:hint="@string/un_login"/>
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/tplPassword"
style="@style/EditText_Style_1"
app:hintTextAppearance="@style/TextLabel"
android:hint="@string/pass_login">

<EditText
android:id="@+id/etPassword"
android:imeOptions="actionNext"
android:inputType="textPassword"
style="@style/EditText_Style_For_All"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>

EditText, when setting to maxLines = 1 and enter is pressed it erases and crashes

Try these together

            android:imeOptions="actionDone"
android:inputType="number"
android:maxLines="1"


Related Topics



Leave a reply



Submit