我有动画:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="0.2"
android:toAlpha="1.0"
android:duration="500"/>
</set>
和 ImageView
:
<ImageView
android:id="@+id/listViewIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/settings"
android:alpha="0.2"/>
并且代码:
final Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
final ImageView iv = (ImageView) findViewById(R.id.listViewIcon);
anim .setFillAfter(true);
iv.startAnimation(anim);
所以一开始我有一个alpha为0.2
的ImageView
,最终我希望它的alpha为1
。但事实并非如此 - 当动画开始时,会增加更多的alpha值,并且动画完成后的alpha值为0.2
。
我需要改变什么来使图像从0.2
逐渐动画到1
?
我已经尝试了不同的设置 - 我设置了android:alpha="1.0"
,fromAlpha="1.0"
,toAlpha="0.2"
,这样就可以按照我的预期工作 - 从1
的alpha值到0.2
。看起来ImageView
中的alpha值与动画中的alpha值相乘...
fillAfter
属性:http://developer.android.com/reference/android/view/animation/Animation.html#attr_android:fillAfter - JavefillEnabled
设置为 true? - Jave