I have a form for member registration in my android app, I have applied the animation effect on fields which are required (some EditText views in this case) if those fields are not filled the effect should occur then like this :
mEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View arg0, boolean arg1) {
            // TODO Auto-generated method stub
            if (mEditText.getText.equals("")) {
                mEditText.setAnimation(MyAnimation.animate());}
and MyAnimation.animate() is like :
public class MyAnimation {
public static Animation animate(){
    TranslateAnimation mAnimate = new TranslateAnimation(0, 5, 0, 0);
    mAnimate.setInterpolator(new CycleInterpolator(50));
    mAnimate.setDuration(600);
    return mAnimate;
}
}
but the problem is it occurs when the mEditText gains the focus, and my need is this should occur on focus leave if mEditText is empty.