Android Custom EditText with Icon

android, user-interface

Solution

you can use

android:drawableLeft="@drawable/your_drawable"

on your EditText in xml.

And from java you can change it like this

Drawable img = getContext().getResources().getDrawable( R.drawable.your_other_drawable );
txtVw.setCompoundDrawablesWithIntrinsicBounds( img, null, null, null );

You'll have to make your own background resources if you want the edit box to have the same rounded/square corners as it does in your example image.

Problem

I'm trying to learn Android and its UI. Would it be possible to create an `EditText` like my design below? Which should include: - Small Icon in the left which should be changeable when an event has occured (guessing this is done programitically) - The right border edge next to the icon - Thick stroke when hovered Can probably work out how to change the icon and thick stroke when an event has occured but do not know how to code the icon with the right border edge inside the `editText` smoothly. Help!

Original source