0

I have added a drawable on the left side of the TextInputLayout (as seen in TextInputEditText below) and want to add some padding below it such that it becomes centred vertically inside its parent. Is there a command or a workaround for this?

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/contact_first_name_input_text"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:hint="@string/contact_first_name"
                android:layout_marginEnd="8dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/contactFirstName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPersonName|textCapWords"
                    android:drawableStart="@drawable/ic_person_black_24dp"
                    android:drawablePadding="8dp"
                    />
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
George
  • 389
  • 5
  • 17

1 Answers1

3

Use the app:startIconDrawable attribute in your TextInputLayout to add a drawable:

<com.google.android.material.textfield.TextInputLayout
       app:startIconDrawable="@drawable/..."

enter image description hereenter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841