1

I am using a textInputEditText and I would like to add a drawable without affect on hint. enter image description here

when I add the drawable the hint has a padding effect.

here is the code:

 <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">  

<com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/cell"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:drawableStart="@drawable/ic_local_phone_black_24dp"
                    android:hint="@string/cell"
                    android:paddingStart="10dp"
                    android:paddingTop="10dp"
                    android:paddingEnd="10dp"
                    android:singleLine="true"
                    android:text="@{personalInfo.phone ?? `-`}"
                    android:textColor="@color/gray_4d"
                    tools:hint="@string/cell"
                    tools:text="362-43-23-5-3" />
            </com.google.android.material.textfield.TextInputLayout>
Molly
  • 1,887
  • 3
  • 17
  • 34
Khaled Qasem
  • 879
  • 7
  • 20
  • You can use only EditText without TextInputLayout. OR set `app:hintEnabled="false"` to TextInputLayout. – Khemraj Sharma Jan 22 '19 at 11:41
  • 1
    Have you tried `android:drawableStart`? – Rumit Patel Jan 22 '19 at 11:46
  • 2
    I think this is the answer you are looking for: https://stackoverflow.com/a/39568320/8969466 – Priya Sindkar Jan 22 '19 at 12:06
  • @PriyaSindkar this link is useful but I will let the question if there is another way or with attributes. and the question for TextInputLayout not editText, may be there is an attribute or another trick for TextInputLayout. Thanks! – Khaled Qasem Jan 22 '19 at 13:43
  • `TextInputLayout` is what's drawing that hint, not the `EditText`, so that's what needs to be modified. Also, there are no attributes to directly set the floating hint position, which is why you need to manipulate its bounds. – Mike M. Jan 23 '19 at 20:05

0 Answers0