I am trying to make the edittext single line. The edittext does comes up as single line but on pressing enter it the cursor comes to the second line and I need to stop this. The singleLine attribute is deprecated so I do not want to use that.
<EditText
android:id="@+id/txtSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:drawablePadding="5dp"
android:lines="1"
android:maxLines="1"
android:inputType="none"
android:scrollHorizontally="true"
android:paddingLeft="5dp"
android:textSize="12sp" />
Can someone let me know what am I goind wrong over here ?
android:imeOptions="actionSend" /> You can then listen for presses on the action button by defining a TextView.OnEditorActionListener for the EditText element. In your listener, respond to the appropriate IME action ID defined in the EditorInfo class, such as IME_ACTION_SEND . For example: Kotlin Java.
Set android:inputType
to something different than "none", use "text", "number" or whatever should be entered in the EditText
. This way you can make the EditText
single-lined. (Of course you shouldn't use "textMultiLine" then ;))
Use this
android:singleLine="true"
instead of,
android:lines="1"
android:maxLines="1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With