0
当我尝试动画自定义视图(在java代码中创建)时,没有效果,动画无法启动。这是我如何做到这一点:动画定制视图类
final Animation animation = AnimationUtils.loadAnimation(this, R.anim.animation);
final CustomView background = new CustomView(this);
background.setBackgroundResource(R.drawable.bg);
background.startAnimation(animation);
CustomView扩展ImageView。
此代码不启动动画,我也尝试ImageView,也不起作用。
只有当我从findViewById(id)获得View时,动画才有效。
这里是动画代码:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="1000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="1.0"
android:startOffset="1000"
android:duration="6000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="7000"
android:duration="1000"
/>
</set>
你可以发布动画的xml代码吗? – 2010-07-16 23:11:12
android:shareInterpolator =“false”属性是无用的,但我从另一个动画应对这个文件,并忘记切割它。 – Fisher 2010-07-17 00:23:03