2016-03-04 42 views
1

enter image description hereEdittext光標在棉花糖rtl中斷支持佈局

我在棉花糖中面臨奇怪的問題。 當語言環境是ar我輸入英文文本,然後光標的EditText打破

參考截圖

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:gravity="left|start" 
    android:hint="@string/app_name" 
    android:inputType="textPassword" 
    android:padding="10dp" 
    android:textAlignment="viewStart" 
    android:textDirection="locale"> 
    <requestFocus/> 

回答

0

設置android:textCursorDrawable="@null"作品對我來說

+0

我有同樣的問題,但不幸的是這並不適用於我 – user3673952

0

也許這兩光標/插入符號的東西有什麼瞭解Android如何管理兩種不同的方向語言(RTL和LTR)。喜歡這個主要和次要的光刻圖片:https://ux.stackexchange.com/a/39639/81811

我想你應該也注意到你的引力。你迫使他們離開和開始。在LTR語言中,文本的開始位於左側,但是當您使用阿拉伯語時,您說您要求左右兩側的重力(因爲RTL語言的開始位於最右側的字符處)。

0

我解決它使用下面..

在你的XML佈局,爲編輯文本字段添加此 - >android:textDirection="anyRtl"

這裏,「EDITTEXT」是你編輯的文本字段的視圖。即

EditText editText = (EditText) findViewById(R.id.edit_text); 

然後以編程方式爲該編輯文本添加文本觀察器。

editText.addTextChangedListener(new TextWatcher() { 
       @Override 
       public void beforeTextChanged(CharSequence s, int start, int count, int after) { 

       } 

       @Override 
       public void onTextChanged(CharSequence s, int start, int before, int count) { 
        editText.setSelection(s.length()); // this line is very important for setting cursor position 
       } 

       @Override 
       public void afterTextChanged(Editable s) { 

       } 
      }); 
     } 

這對我有效!

0

嗨我也有基於rtl的語言環境相同的問題。 所以我做了以下屬性EditText

android:textDirection="ltr" 
android:textAlignment="viewStart" 
android:gravity="start" 

以上特性已經固定在兩個光標問題

上述性質指出,我們設計EditTextleft to right(ltr)

一個和文字應該從left i.e start開始。 因此,操作系統將逆轉rtl locale的方向。

這對阿拉伯語言有完美的rtl