i m new to this android application development field i went through the code that would provide shaking feature but i m unable to understand that for writing this shaking code I have to create new project or i can add this code in my existing app like gallery (example given in tutorials of android development) If so then how??? plzzzz reply
Asked
Active
Viewed 1,573 times
2 Answers
2
Hello swati sinha You hav to use android shake animation. here some hints suppose you want to add shake animation to Edittext.
Animation animationShake= AnimationUtils.loadAnimation(this, R.anim.shake);
if(editext.getText().lenght()==0){
edittext.startAnimation(animationShake);
}
and shake.xml looks like
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="10" android:duration="1000"
android:interpolator="@anim/cycle_7" />
and cycle_7.xml looks like
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
both cycle_7 and shake xml file shud be under res/anim folder. if You find my answer useful chek as accepted answer

Krishna Shrestha
- 1,662
- 14
- 38
1
-
Thanx!! for the reply ...... can i see this shaking feature on emulator after implementing it? – swati sinha Jun 03 '12 at 13:48
-
Nope, not that I know of Swati, you should be able to try this on any android device. Even low end ones. – Soham Jun 04 '12 at 10:27