I'm trying to add an Left Icon to my TextInputLayout, but text get over the Icon. When I add a padding, everything move together.
I tried with
android:drawableLeft="@drawable/ic_store_white_48dp" android:drawablePadding="50dp" android:drawableStart="@drawable/ic_store_white_48dp"
But it is not working ! I should implement a LinearLayout horizontal for each row, but I would like to be sure there is no easier way to do it
Here is my code layout:
<android.support.design.widget.TextInputLayout android:id="@+id/til_calle" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/et_calle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawableLeft="@drawable/ic_store_white_48dp" android:drawablePadding="50dp" android:drawableStart="@drawable/ic_store_white_48dp" android:hint="Calle" android:inputType="text" /> </android.support.design.widget.TextInputLayout>
Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it.
You can just set the start and end padding on the inner EditText to 0dp. Here's a screenshot with Show Layout Bounds turned on so you can see that the hints go all the way to the edge of the view.
Make sure you are using the latest Design
library, all you need for both Design
and AppCompat
is:
compile 'com.android.support:design:23.2.0'
Try using both the Design's library TextInputLayout
and AppCompat's AppCompatEditText
.
<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:drawableLeft="@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"/> </android.support.design.widget.TextInputLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With