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?
Asked
Active
Viewed 3,833 times
5
-
1Have a look at this question: http://stackoverflow.com/questions/3703283/how-can-i-add-an-image-on-edittext – ebarrenechea Mar 13 '13 at 18:30
-
That link solves the problem is Java. The answer deserves merit because it solves in XML. – nipponese Mar 13 '13 at 20:19
2 Answers
8
To set the image in editText.
<EditText
......
android:drawableLeft="@drawable/image" />
You can set it Left, Right, Top, Bottom.

Ajay S
- 48,003
- 27
- 91
- 111
1
Just use the
setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
or
setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
methods.
Cheers

darksaga
- 2,166
- 2
- 18
- 21