在写文章之前提一下samples,里面有很多Android初学者可以学的东西,本文的效果也是来自其中。
其实samples在AS中的模拟器中就有展示的效果(API Demos)
代码如下:
java文件中代码调用:
Animation shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.shake);
mEtPhone.startAnimation(shake);
shake.xml文件:
<?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" />
cycle_7.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
欢迎留言