Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

android - 如何将光标放在EditText的右侧(How do I position the cursor on the right in EditText)

My application uses RTL language (right to left).

(我的应用程序使用RTL语言 (从右到左)。)

When the EditText field gets focus, the cursor appears on the left and only when the user starts to type, the cursor (and the RTL text) moves right.

(当EditText字段获得焦点时,光标将显示在左侧,并且仅当用户开始键入时,光标(和RTL文本)才向右移动。)

When the user clicks "enter" to start a new line, the cursor moves to the left again.

(当用户单击“输入”以开始新行时,光标再次移至左侧。)

When I use android:gravity="right" , the cursor is OK (on the right) but as the user starts to type the text always moves to the the other side (RTL text moves left).

(当我使用android:gravity="right" ,光标是可以的(在右侧),但是当用户开始键入时,文本总是移到另一侧(RTL文本向左移动)。)

Any ideas how I can align text to the right AND keep the text direction?

(有什么想法可以使文本向右对齐并保持文本方向吗?)

  ask by Asaf Pinhassi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Its works for me

(它对我有用)

      <EditText
            android:id="@+id/editText1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:ellipsize="end"
            android:gravity="right" />

ellipsize is important

(ellipsize很重要)

It solves your problem

(它解决了你的问题)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...