Android Custom EditText with icon

I am trying to learn Android and its interface. Can I create EditTextas my project below?

EditText Design

What should include:

  • A small icon on the left that should be changed when an event occurs (assuming that this is done programmatically)
  • The right edge of the border next to the icon
  • Thick stroke when freezing

You may be able to decide how to change the icon and the thick stroke when the event occurred, but I don’t know how to correctly encode the icon with the correct border edge inside EditText. Help!

+5
source share
1 answer

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 );

, , / , .

+5

All Articles