sahar
sahar

Reputation: 117

hint didn't work in edittext in android

I use Hint and it works in emulator, but when I install the code in the phone, Hint doesn't work.

<EditText 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:hint="نام"
    android:gravity="right"
    android:id="@+id/fname" 
    android:singleLine="true"
    android:imeActionLabel="Next"> 
</EditText>
<EditText 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:hint="نام خانوادگی"
    android:gravity="right"
    android:id="@+id/lname" 
    android:singleLine="true"
    android:imeActionLabel="Next">
</EditText>

Any idea?

Upvotes: 1

Views: 658

Answers (3)

Keivan Esbati
Keivan Esbati

Reputation: 3454

This issue is actually an infamous bug in android EditText. When using singleLine="true" or maxLines="1" or generally anything that trigger android:scrollHorizontally="true" the EditText in Layout stage fail to render RtL hint correctly..

If your language layout direction is RtL you can simply solve this problem by setting gravity="right|center_vertical" to your EditText.

P.S: This Issue has been on IssueTracker for a long time but there hasn't been any fix since. You can help this issue resolves faster by starring this issue: https://issuetracker.google.com/issues/36924615

Upvotes: 1

Mohammad
Mohammad

Reputation: 11

the hint as Persian or other Unicode language when you define InputType for EditBox doesn't
show. you should delete the

android:inputType="..."

Upvotes: 0

Ram kiran Pachigolla
Ram kiran Pachigolla

Reputation: 21181

Copy the String in the strings.xml (means your relevant language) and then give the hint as

android:hint="@string/strname"

<resources>

  <string name="strname">نام خانوادگی</string>

</resources>

The above will be work if the device will support your language.

android:singleLine="true" remove this from your edittexts then you can see the hints

Upvotes: 3

Related Questions