Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Custom EditText layout with XML

I am trying to customize the look of an EditText but I am failing to do so... I would like to have the textfield in rounded borders with a graphic icon to the left (so the icon would be inside the borders too, next to the edittext). Could somebody please explain me how I could achieve this? Do I need to draw the border as a shape or is there some property for this? Thanks a lot!

like image 218
Fygo Avatar asked Jan 30 '13 06:01

Fygo


2 Answers

Try like this

                <EditText
                    android:id="@+id/rLastName"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/editbox"
                    android:hint="@string/lname"
                    android:padding="5dip"
                    android:singleLine="true"
                    android:textColor="#999999"
                     android:textSize="14dip"                          
                    android:drawableLeft="@drawable/ic_launcher" /> 

Drawable left the icon will be set in left side

enter image description here

You can try this link for rounded corners link

like image 51
Janmejoy Avatar answered Nov 14 '22 08:11

Janmejoy


How to create EditText with rounded corners?
And
http://alinberce.wordpress.com/2012/02/20/android-edittext-with-custom-font-and-clear-button/

like image 43
Anukool Avatar answered Nov 14 '22 09:11

Anukool