Reputation: 2810
MaxLines attribute in Edit text is not working:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColorHint="@color/colorAccent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/register_userName"
android:maxLines="1"
android:textColorHint="@color/colorAccent"
android:textColor="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name" />
</android.support.design.widget.TextInputLayout>
I'm using following in my gradle:
compileSdkVersion 25
buildToolsVersion '25.0.2'
Though I Have specified android:maxLines="1"
for my edit text, the edit text shifting to new line I'm testing on Android 5.1, this worked fine on my previous apps but I recently updated my build tools and I'm not sure why android:maxLines="1"
is not working as expected.
Upvotes: 2
Views: 8472
Reputation: 2940
Even though it seems to be working with android:inputType="text"
the docs say it must be used with textMultiLine
Makes the TextView be at most this many lines tall. When used on an editable text, the inputType attribute's value must be combined with the textMultiLine flag for the maxLines attribute to apply.
Upvotes: 1
Reputation: 1615
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
Upvotes: 12
Reputation: 5550
Add proper EditText
line values:
android:lines="1"
android:minLines="1"
android:maxLines="1"
Using all 3 implies to single line.
Upvotes: 1
Reputation: 2434
android:singleLine="true"
is deprecated. Try to add
android:inputType="text"
Upvotes: 1