Double cursor in EditText for Input Type Number/Phone (RTL Arabic)

為{幸葍}努か 提交于 2019-12-05 12:54:47

The Edit text doesn't know if the next char you will press is a number or a letter so in case of a letter it places the far left one while the far right one for a number(Most likely you know that just making sure).

So it will disappear if you switch to English.

I think this is fundamental in the edit text:

Solutions:

1- You can create your own edit text from scratch(From View).(May take month with all the problems that may arise).

2- Find a way to override the edit text to remove the split.

3- Find a git where someone had solved that problem(which I doubt).


This doesn't seem like a problem as a programmer or a user. A designer maybe will be a bit annoyed but ignoring it is the fastest way.

Sorry if this wasn't usefull.

Use properties layout_direction as 'ltr' and gravity 'right'.

      <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/phone"
            android:inputType="number"
            android:lines="1"
            android:maxLines="1"
            android:gravity="right" />

This solved my problem.

ViewCompat.setLayoutDirection(findViewById(R.id.myedittext), ViewCompat.LAYOUT_DIRECTION_LTR);

it worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!