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
Recyclerview Changing Items During Scroll
Navigationview and Custom Layout
How to Move the Layout Up When the Soft Keyboard Is Shown Android
Open Soft Keyboard Programmatically
Java.Lang.Nullpointerexception (No Error Message)
How to Make an Http Request Using Cookies on Flutter
Android - Spacing Between Checkbox and Text
Why Is Eclipse's Android Device Chooser Not Showing My Android Device
Jni and Gradle in Android Studio
The Import Android.Support.V7 Cannot Be Resolved
Programmatically Obtain the Android API Level of a Device
Gradle Error: Minimum Supported Gradle Version Is 3.3. Current Version Is 3.2
Android Mediaplayer Throwing "Prepare Failed.: Status=0X1" on 2.1, Works on 2.2