Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Left Icon in TextInputLayout

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> 
like image 329
Juliatzin Avatar asked Jun 19 '15 16:06

Juliatzin


People also ask

How do I remove TextInputLayout error?

Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it.

How do I remove the default padding in TextInputLayout?

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.


1 Answers

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> 
like image 156
Jared Burrows Avatar answered Oct 20 '22 11:10

Jared Burrows