How to set the cursor to the right with right align and hint text?
Is it possible?
I have a AutoCompleteTextView and a EditText with Text right align and an hint text. Now if one of them is focused the curser is before the hint and not at the end of the line. So it looks like now it's bad...
I've also tried to set the cursor position, but it didn't help of course.
<AutoCompleteTextView
android:id="@+id/input_snm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/input_ipAdresse"
android:ems="10"
android:gravity="right"
android:hint="@string/input_snm"
android:imeActionLabel="@string/Button_berechnen"
android:imeOptions="actionDone|flagNoExtractUi"
android:inputType="phone"
android:paddingRight="@dimen/padding_small"
android:textSize="@dimen/fontsize_medium" />
Image: EditText
Ok, I think it's an System error, isn't it?
Say in your xml's edittext section, add android:paddingLeft="100dp" This will move your start position of cursor 100dp right from left end. Same way, you can use android:paddingRight="100dp" This will move your end position of cursor 100dp left from right end.
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.
Simpler Solution to align text in EditText is to add android:gravity="center" in layout xml. There is no need to add Java code.
Set the android:Theme.Light
style on the activity (theme) and android:gravity="right"
.
You can use like this:
if (your_edittext.getText().length() > 0 ) {
your_edittext.setSelection(your_edittext.getText().length());
}
Can you add this line to your EditText
xml
android:gravity="right"
android:ellipsize="end"
android:paddingLeft="10dp"//you set this as you need
But when any Text writing you should set the paddingleft to zero
you should use this on addTextChangedListener
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