android实现抖动效果

实现抖动是采用的Animation动画
shake.xml文件
<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文件
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" 
	android:cycles="7" />


使用这个效果,只需下面两行代码:
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
        findViewById(R.id.xxxx).startAnimation(shake);

猜你喜欢

转载自goblin-god.iteye.com/blog/1146656