Hint Alignment to the right of password EditText

textinputlayout
android set text direction programmatically
android:text input
xml text direction

I'm working on and activity with arabic language. I want the hint of the username and password to start from the right and I have no problem f typing started from the left but in my UI I want the hint to be of the right side. But when I'm adding the inputType for the EditText the hint moves to the left.I tried solving it programmatically but it didn't work.

Java

    EditText password = (EditText) findViewById(R.id.input_password);
    password.setTypeface(Typeface.DEFAULT);

XML

<EditText
            android:id="@+id/input_password"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="كلمة المرور"
            android:textColorHint="#FFFFFF"
            android:inputType="textPassword"
            android:background="@null"
            android:textColor="#FFFFFF"
            android:textSize="20dp"/>

android - Password edittext hint text alignment on right side, I'm facing an issue that when I define an EditText as password type and view my screen in Arabic language the password field hint text is showing on the left  To make the hint display properly on the right (in right-to-left/RTL mode), you must remove the InputType property textPassword (InputType.TYPE_TEXT_VARIATION_PASSWORD), when there is no text entered.


Use Gravity Attribute to Adjust the Hint for EditText

        <EditText
        android:id="@+id/input_password"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:hint="كلمة المرور"
        android:textColorHint="#FFFFFF"
        android:gravity="right"
        android:inputType="textPassword"
        android:background="@null"
        android:textColor="#FFFFFF"
        android:textSize="20dp"/>

Hint Alignment to the right of password EditText, I'm working on and activity with arabic language. I want the hint of the username and password to start from the right and I have no problem f typing started from  To make the hint display properly on the right (in right-to-left/RTL mode), you must remove the InputType property textPassword ( InputType.TYPE_TEXT_VARIATION_PASSWORD ), when there is no text entered. To retain the password entry field behaviour of showing dots to conceal typed text, you must dynamically enable InputType.TYPE_TEXT_VARIATION_PASSWORD, when the first character is entered in.


add gravity right try this way

<EditText
            android:id="@+id/input_password"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="كلمة المرور"
            android:textColorHint="#FFFFFF"
            android:inputType="textPassword"
            android:background="@null"
            android:textColor="#FFFFFF"
            android:textSize="20dp"
            android:gravity="right"/>

if your API level 17 and higher you can use

android:textDirection="anyRtl"

cursor in EditText hint does not start from right for Arabic, I'm trying to make EditText with a hint text: In English "password" .. the cursor is correctly set to the left. But for Hint Alignment to the right of password EditText. Starts EditText hint text from middle of form box like set alignment center using gravity attribute. Normally after adding hint text into EditText it will automatically starts from left side but some times appliction developer needs some special requirement in their projects so as their project requirement app builder can set edittext hint alignment using gravity attribute to starts hit in


For AppCompatEditText edit text gravity start worked for me

<androidx.appcompat.widget.AppCompatEditText
        ......
        android:hint="كلمه السر"
        android:inputType="textPassword"
        android:gravity="start"
       .............../>

This will work only above api 16

you can also try, Where you must have stored your current language I used this library com.akexorcist:localizationactivity

if(currentLanguage.country.toLowerCase() == "arabic"){
        etPassword.gravity = GravityCompat.END
}else{
        etPassword.gravity = GravityCompat.START
}

EditText, When you define an edit text widget, you must specify the R.styleable.​TextView_inputType attribute. For example, for plain text input set inputType to "​text":. I created an EditText that was centered but the hint text was left aligned with no way to change it. 👍 5 Hixie added severe: new feature framework f: material design labels Mar 2, 2018


Use 'gravity' attribute:

<EditText
    android:id="@+id/input_password"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hint="كلمة المرور"
    android:textColorHint="#FFFFFF"
    android:gravity="right"
    android:inputType="textPassword"
    android:background="@null"
    android:textColor="#FFFFFF"
    android:textSize="20dp"/>

android.widget.TextView, android:drawableRight, The drawable to be drawn to the right of the text. android:gravity, Specifies how to align the text by the view's x- and/or y-axis when the the characters of the field are displayed as password dots instead of themselves. Note that this feature is not supported by EditText, works only for TextView. EditText editText = (EditText)findViewById(R.id.simpleEditText); editText.setText("Username");//set the text in edit text. 4. hint: hint is an attribute used to set the hint i.e. what you want user to enter in this edit text. Whenever user start to type in edit text the hint will automatically disappear.


EditText Tutorial With Example In Android Studio: Input Field, attribute which is used to control the alignment of the text like left, right, center, top, bottom, Whenever user start to type in edit text the hint will automatically disappear. android:layout_centerInParent="true" android:text="Password" 10​. padding: padding attribute is used to set the padding from left, right, top or bottom. There is an issue with Hint Text alignment. I want right aligned TextField. I set the property to textAlign: TextAlign.end, by doing this actual text is now starting from right side( which is correct) but the hint text still starting from left(it should also be on the right side of text field).


Android EditText with Examples, I'm working on and activity with arabic language. I want the hint of the username and password to start from the right and I have no problem f typing started from  Hi and welcome to another tutorial from Codingdemos, today we are going to learn how to improve the appearance of an android edittext by adding an icon.Having an Android edittext icon gives the user an idea of the type of data which they need to fill-in.


Android TextInputLayout Example, In case if EditText field is for password, then we need to specify the inputType as android:gravity, It is used to specify how to align the text like left, right, center, top, etc. android:hint, It is used to display the hint text when text is empty. While using EditText control in our android applications, we need to specify the type of data the text field can accept using the inputType attribute. For example, if it accept plain text, then we need to specify the inputType as “text”. In case if EditText field is for password, then we need to specify the inputType as “textPassword”.