Naveed Ali
Naveed Ali

Reputation: 2619

Setting EditText left or right drawable with animation

I want to add simple fade animation over EditText on setting the left or right drawable.

Is there any simple workaround for this?

 edtText.setCompoundDrawablesWithIntrinsicBounds(0,
            0, drawableResId, 0)

Upvotes: 1

Views: 105

Answers (1)

jeprubio
jeprubio

Reputation: 18002

If your drawable is animated like an AnimationDrawable you could do:

AnimationDrawable d = (AnimationDrawable) getResources()
    .getDrawable(R.drawable.whatever_drawable);
edtText.setCompoundDrawablesWithIntrinsicBounds(null, null, d, null);
d.start();

d.start should start the animation and at some point you should call d.stop() to stop it.

Upvotes: 1

Related Questions