I want to restrict the edittext entry to a single line but When I add the line android:singleline = "true"
, the hint is disappears, and after entering 26 characters the cursor is coming down.
Here's my XML code:
<EditText
android:background="@drawable/edittxtborder"
android:id="@+id/reglastname"
android:singleLine="true"
android:gravity="center"
android:hint="@string/reglname"
android:textSize="12dp"
/>
Save this question. Show activity on this post. But it told me editable is deprecated ,you can use inputType instead.
In android, we can set the text of EditText control either while declaring it in Layout file or by using setText() method in Activity file.
The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.
add this code in your edittext xml code.
android:ellipsize="end"
this will work.
Use value for the attribute inputType
other than textMultiLine
. The input will be single line. The attribute singleLine
is deprecated.
I checked your code and the problem is with android:gravity="center". Change it to android:gravity="left" and you will be able to see the hint.
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