I've got animation:
<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>
and ImageView
:
<ImageView
android:id="@+id/listViewIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/settings"
android:alpha="0.2"/>
and code:
final Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
final ImageView iv = (ImageView) findViewById(R.id.listViewIcon);
anim .setFillAfter(true);
iv.startAnimation(anim);
So at the beginning I have ImageView
with alpha 0.2
and at the end I want to have ImageView
with alpha 1
. But it doesn't work like that - when animation starts more alpha is added and animation finish with alpha 0.2
What do I have to change to animate my image from 0.2
up to 1
?
I've checked with different settings - I set android:alpha="1.0"
, fromAlpa="1.0"
, toAlpha="0.2"
it works like I expected - from alpha 1
to 0.2
. It looks like alpha from ImageView
is multiplied by alpha from animation...
Try this
AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
animation1.setDuration(1000);
animation1.setStartOffset(5000);
animation1.setFillAfter(true);
iv.startAnimation(animation1);