Reputation: 521
I have a login screen that consists of two EditText views.
username & password fields.
When i change the language to Arabic, the password Edit text field gets right aligned.
I dont know about RTL language rules, but i feel it is starting to work according to RTL language rules.
Username field is not effected . But password field gets right aligned.
Password Text :
<EditText
android:id="@+id/login_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:inputType="textPassword"
android:hint="@string/login_input_password_hint" />
username :
<EditText
android:id="@+id/login_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:inputType="texturi"
android:hint="@string/login_input_userid_hint" />
I feel the problem is with == android:inputType="textPassword" Please tell me how to rectify this issue.
Upvotes: 2
Views: 4567
Reputation: 1
First, you can get the location information and process accordingly.
If the location shows arabia, you can set gravity to your EditText.
Use android:inputType="textPassword"
And Check (Kotlin code) :
val locale = Locale.getDefault().language
if (locale == "ar") {
yourEdittext.gravity = Gravity.RIGHT
} else {
yourEdittext.gravity = Gravity.LEFT
}
Upvotes: 0
Reputation: 352
I don't have idea what is the reason of this issue but you can us text alignment as
android:gravity="left"
android:textAlignment="gravity"
Upvotes: 1