-11

For Android EditText maxlines=true does not work if digits are applied and single line true is deprecated so anyone has any suggestions?

Phantômaxx
  • 36,442
  • 21
  • 78
  • 108
Rudee
  • 19
  • 2

3 Answers3

2

see this example

<EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="4dp"
        android:digits="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        android:maxLength="15"//used to set max character
        android:maxLines="1"/>//used to set max number of lines

enter image description here

Akshay Katariya
  • 1,366
  • 8
  • 19
0

Put this code in your activity

editText = (EditText) findViewById(R.id.editText);
editText.setSingleLine(true);

This is how your xml will look

<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyz"
android:maxLines="1"
android:textColor="@android:color/black"/>
Akshay Katariya
  • 1,366
  • 8
  • 19
Arjun Solanki
  • 196
  • 1
  • 10
0

I think you didnt specify this parameter:

android:inputType="text" 

Without it you can even put new line in edit text. You could add also these attributes:

 android:maxLines="1"
 android:lines="1"

Though when I checked it without inputType attribute, it still didn't work. Hope I helped

M. Wojcik
  • 1,058
  • 2
  • 13
  • 23