Kyle Banks

Open Sourced: IconEditText for Android

Written by @kylewbanks on Sep 5, 2015.

IconEditText provides a reusable view for displaying an ImageView with an EditText for Android 4.0+.

Note: For more up-to-date documentation, check GitHub.


Using the IconEditText is easy enough, just clone the repo and add it to your project as a Library.

After adding the library, you can add an IconEditText like so:


<!-- Note the declaration of the `widget` namespace. -->

      widget:iconSrc="@drawable/username_icon" />



The IconEditText currently supports the following properties:

  • isPassword {Boolean}: If true, will mask the EditText's input.
  • hint {String}: The hint text to display, if any.
  • iconSrc {Drawable}: The source of the icon image to display.


From Java, you can reference the IconEditText like any other view. For example, from an Activity:

IconEditText iconEditText = (IconEditText) findViewById(...);

You can access the underlying EditText and ImageView like so:

EditText editText = iconEditText.getEditText();
ImageView imageView = iconEditText.getImageView();

There is also a convenience method for accessing the EditText's Editable:

Editable editable = iconEditText.getText();


Contributions are always welcome, so don't hesitate to head over to GitHub and submit a pull-request.

Let me know if this post was helpful on Twitter @kylewbanks or down below, and follow me to keep up with future posts!