MathanMV
MathanMV

Reputation: 412

Android Custom EditText with Icon

I'm trying to learn Android and its UI. Would it be possible to create an EditText like my design below?

EditText Design

Which should include:

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!

Upvotes: 5

Views: 8028

Answers (1)

FoamyGuy
FoamyGuy

Reputation: 46856

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.

Upvotes: 5

Related Questions