Select text for right gravity, doesn't work in EditText control in HTC devices

122 Views Asked by At

I'm developing an Android application in which I have an EditText control. I've set the gravity to right, in order to type in Persian. But when I try to select a text (which is in Persian), the select pointers won't appear. It works almost fine when the gravity is not set. Also it works fine in other devices like Samsung. But it doesn't work on HTC devices (HTC One xl in my case).

This is my EditText xml

 <EditText
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:id="@+id/txtShare" 
       android:layout_weight="1" 
       android:enabled="true"
       android:inputType="text|textMultiLine"
       android:hint="@string/typeHere" 
       android:gravity="right"/>

Does anyone know how to fix this?

Edit 1

Also the cursor is always at the beginning of the lines, no matter where I tap in the text.

Edit 2

I'm almost sure that if I can solve the problem in Edit 1, the first problem will be solved along with it. Cause wherever I click in text, the cursor would remain in the beginning of the line

3

There are 3 best solutions below

0
Myat Min Soe On

Try adding following attribute to your EditText

android:ellipsize="end"
1
Punksmurf On

If you are using right-to-left text you should use the textDirection property for correct support. Gravity only aligns text, so text you enter would still be left-to-right.

0
Sandy Lin On

The cursor selection is handled in the onTouchEvent method.

I don't have any HTC device, so just an idea.

Maybe you can try to find the problem from the onTouchEvent method.