Adding shake effect in Android

To add a shake effect to a textbox when an error occurs, first add the following 2 XML files in your anim folder

<-- ../main/res/anim/shake.xml -->
1) Control how fast or slow the shake should be in this file.
2) Control how far the shake go from left to right.

<-- ../main/res/anim/cycle.xml -->
Control how many times you want the shake animation to occur.

Now, use the below code snippet to add shake animation to textbox in your code.
Following code using shake to grab users attention to an error in the email address field.