2016-02-13 29 views
5

मुझे आरटीएल भाषाओं में एंड्रॉइड इनपुट कर्सर के साथ समस्या है। जब मैं आरटीएल समर्थन लेआउट में हूं, मेरे पास दो इनपुट कर्सर हैं और यह वास्तव में मजाकिया है। क्या इसका वास्तविक समाधान है, इससे छुटकारा पाने के लिए?आरटीएल भाषाओं में एंड्रॉइड कर्सर

मैं अपने एंड्रॉयड यूआई RTL बनाने के लिए इस कोड का उपयोग:

getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); 

और पाठ दृश्य के लिए इसे मेरा xml:

<android.support.design.widget.TextInputLayout 
     android:id="@+id/input_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="numberDecimal" 
      android:id="@+id/myID" 
      android:maxLines="1" 
      android:focusableInTouchMode="true" 
      android:layout_weight="0.25" 
      android:layout_gravity="center_horizontal" 
      android:hint="phone Number" 
      android:maxLength="20" 
      android:gravity="center" /> 
    </android.support.design.widget.TextInputLayout> 

enter image description here

+0

ऐसा हो सकता है कि आपने केंद्र में edittext गुरुत्वाकर्षण सेट किया है और कर्सर उलझन में आया है। ऐसा नहीं होना चाहिए, लेकिन सही गुरुत्वाकर्षण छोड़ने का प्रयास करें तो समस्या नहीं आ सकती है। बेहतर आप गुरुत्वाकर्षण मूल्य –

+0

@ क्रिएटिव एंड्रॉइड मैंने आपके द्वारा जो कुछ भी कहा और अभी भी वही समस्या शुरू की है। –

+0

अपने edittext xml –

उत्तर

1

मैं समस्या का समाधान। बस संपादन टेक्स्ट भाषा को बाएं से दाएं बनाएं और समस्या हल हो गई है।

<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:inputType="number" 
    android:ems="10" 
    android:id="@+id/PhoneNoET" 
    android:layout_marginTop="64dp" 
    android:layout_below="@+id/textView6" 
    android:layout_centerHorizontal="true" 
    android:textAlignment="center" 
    android:maxLength="11" 
    android:layoutDirection="ltr"/> 

उपर्युक्त लेआउट जोड़ें अपने संपादन टेक्स्ट में सुधार और समस्या को ठीक करें। > अपने संपादित पाठ क्षेत्र को देखते

android:textDirection="anyRtl" 

यहाँ, "editText" है -

0

मैं नीचे का उपयोग कर इसका समाधान नहीं होता ..

अपने XML लेआउट में, संपादित पाठ क्षेत्र के लिए इस जोड़ें। i.e,

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) { 

       } 
      }); 
     } 

यह मेरे लिए काम करता है!

संबंधित मुद्दे