2015-07-20 134 views
0

这里是xml代码。Shake动画无法正常工作

<?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" /> 

这是我使用它的方式。

android:repeatCount="7" 
android:repeatMode="reverse" 

这应该做的伎俩:

final Animation animAlpha2 = AnimationUtils.loadAnimation(this, R.anim.anim); 
v.startAnimtion(anumAlpha2); 
+0

你是什么意思“不能正常工作”? –

+0

我的意思是它甚至没有对组件摇晃。 –

+0

尝试在android:toXDelta =“10%”中使用百分比。 10px对你来说太小了,没有注意到任何东西。 –

回答

3

通过更换android:interpolator="@anim/cycle_7"线。 repeatCount设置动画将执行的周期数和repeatMode,其可以假设为two values,repeatrestart