读书人

文本颤动效果

发布时间: 2012-09-03 09:48:39 作者: rapoo

文本抖动效果
几句代码如下:
Java代码
Animation animation = AnimationUtils.loadAnimation(this, R.anim.shake);
EditText editText = (EditText) findViewById(R.id.edittext);
editText.startAnimation(animation);

Animation animation = AnimationUtils.loadAnimation(this, R.anim.shake);
EditText editText = (EditText) findViewById(R.id.edittext);
editText.startAnimation(animation);


shake.xml:
里面面的fromXDelta,toXDelta是表示x轴方向的移动距离
Java代码
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="30" android:duration="1000"
android:interpolator="@anim/cycle_interpolator" />

<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="30" android:duration="1000"
android:interpolator="@anim/cycle_interpolator" />


cycleInterpolator.xml文件:
Java代码
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="3" />

读书人网 >移动开发

热点推荐