Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put images in a EditText field? [duplicate]

I'd like to put an image in an EditText field, as shown. How should one go about this? Layered-list with the image on one layer and a lot of padding on the left side of the EditText on the other layer?

enter image description here

like image 835
nipponese Avatar asked Mar 13 '13 18:03

nipponese


2 Answers

To set the image in editText.

<EditText
   ......  
    android:drawableLeft="@drawable/image" />

You can set it Left, Right, Top, Bottom.

like image 106
Ajay S Avatar answered Oct 24 '22 00:10

Ajay S


Just use the

setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)

or

setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)

methods.

Cheers

like image 1
darksaga Avatar answered Oct 24 '22 00:10

darksaga