用于输入类型编号/电话的EditText中的双光标(RTL阿拉伯语) [英] Double cursor in EditText for Input Type Number/Phone (RTL Arabic)
问题描述
我有一个EditText设置为Right Right,如果语言是阿拉伯语,则文本从右边开始.
I have an EditText set to gravity Right, so that the text starts from the right if the language is Arabic.
注意:我的应用程序支持RTL,并且我没有为EditText设置TextDirection,因为那样会出现相同的问题.将重力"设置为右"可以完美地完成工作.仅当我将InputType设置为Number或Phone时,我才遇到问题.
Note: My application supports RTL, and I am not setting the TextDirection for my EditText as that will have the same problem. Gravity set to Right does the job perfectly. I have an issue only if I set the InputType to Number or Phone.
如果InputType设置为数字/电话,则在文本的开头和结尾处都将出现两个光标,这会造成一些混乱.
If the InputType is set to number/phone there are double cursor at the beginning and end of the text and it is a bit confusing.
为了证明这一点,我有两个EditText,它们的InputType Text和Number的Gravity都设置为Right.我的应用程序支持RTL,并且我的手机现在设置为阿拉伯语
To demonstrate this, I have two EditText with InputType Text and Number, Gravity set to Right for both. My application supports RTL and My phone is now set to Arabic language
清单
android:supportsRtl="true"
XML
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="text"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android: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"
/>
这是第二个具有InputType Number的EditText的行为的屏幕截图.
Here is a screen shot of the behaviour for the second EditText with InputType Number.
关于如何摆脱双光标的任何指针?或其他任何选择.
Any pointers on how to get rid of the double cursor? or any alternative.
谢谢 R
推荐答案
使用layout_direction属性作为'ltr'和重力'right'.
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" />
这解决了我的问题.
这篇关于用于输入类型编号/电话的EditText中的双光标(RTL阿拉伯语)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!