Add an icon to EditText

How can I add an icon in the input field EditText, Example:

enter a description of the image here

Source code:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignWithParentIfMissing="false"
    android:layout_centerHorizontal="true"
    android:layout_toRightOf="@+id/imageMode"
    style="@style/Base.Theme.AppCompat.Light"
    android:paddingBottom="10dp"
    android:layout_marginLeft="48dp"
    android:layout_marginRight="48dp">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Пароль"
        android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
Author: Vitaliy Sivolotskiy, 2015-09-14

1 answers

The simplest option is to add this line to the EditText:

<EditText
    ...
    android:drawableLeft="@drawable/my_icon"
    ...
/>
 7
Author: ermak0ff, 2015-09-14 08:35:07