Zakaria M. Jawas
Zakaria M. Jawas

Reputation: 477

How to change the position of the show password icon in layout

I want to change the position of the eye-icon to the left.

inputype of edittext as textPassword

I'm developing an Arabic app, so the text inside the EditText will be aligned to the right. Any idea on how to do this?

My code:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/txt_password"
        android:layout_width="match_parent"
        android:layout_height="34dp"
        android:hint="@string/prompt_password"
        android:imeActionLabel="@string/action_sign_in"
        android:imeOptions="actionUnspecified"
        android:inputType="textPassword"
        android:maxLines="1" />

</android.support.design.widget.TextInputLayout>

Upvotes: 1

Views: 997

Answers (4)

Tarique Khan
Tarique Khan

Reputation: 1

Use android:gravity="right" in EditText, the text inside the EditText will be aligned to the right.

Upvotes: 0

Chayan Chowdhury
Chayan Chowdhury

Reputation: 129

Please check with this.

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:textColorHint="@color/loginHint">

<android.support.v7.widget.AppCompatEditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:imeOptions="actionNext"
    android:inputType="textEmailAddress|textNoSuggestions"
    android:minWidth="350dp"
    android:drawableRight="@drawable/ic_store_white_48dp"
    android:drawableStart="@drawable/ic_store_white_48dp"
    android:textColor="@android:color/white"
    android:textColorHint="@color/loginHint"
    android:textCursorDrawable="@null"
    app:backgroundTint="@android:color/white"/>

Upvotes: 0

Madhav
Madhav

Reputation: 283

Use the following code

<EditText 
 android:id="@+id/inputSearch"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:gravity="right"
 android:drawableLeft="@android:drawable/ic_menu_search"/>

Upvotes: 1

 <EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textVisiblePassword"
    android:text="Name"
    android:drawableStart="@drawable/ic_search_in"
    android:id="@+id/editText2"/>

Upvotes: 1

Related Questions