Using the frame layout it is very easy to overcome this.Here another advantage is that you can give click events for buttons.if you set icons using setCompoundDrawables, you cant give the click events.I have implemented in my project that search bar has delete and search icons.
You can use:
as suggested here:
Calling setCompoundDrawables() doesn't display the Compound Drawable
Create an instance of the
EditText
Then create a drawable instance of the image
OR
Then set the image by calling
setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom);
The above line will set the image in the right side of the
EditText
using
android:drawableRight
orandroid:drawableLeft
(depend where you prefer align image)you can also try this
Using the frame layout it is very easy to overcome this.Here another advantage is that you can give click events for buttons.if you set icons using setCompoundDrawables, you cant give the click events.I have implemented in my project that search bar has delete and search icons.