I have an ImageView element that I create in my code and place inside of my RelativeLayout. I set this image to be Invisible to start off with using the following code:
arrow.setVisibility(View.INVISIBLE);
I then defined a Fade-In Alpha animation via XML:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:fillEnabled="true"
android:fillAfter="true"
android:fillBefore="true">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:startOffset="100"
android:duration="300" />
/set>
To run the animation:
I simply call the following to start the animation
myview.startAnimation(myanimation);
The issue I am seeing is that my animation causes the ImageView to flicker in at full visibility and then go through the animation of alpha 0 to 1. How do I fix this? I can't set the initial alpha value to 0 because the alpha animation is based on percentage and not absolute alpha value. (ex: 0*current value to 1*current value)
Any help would be greatly appreciated.
An Alpha Animation is animation that controls the alpha level of an object, i.e. fading it in and out.
Use clearAnimation() to stop an animation.
I think the problem is, with this line of code:
android:fillBefore="true"
Here, Try this code instead, it works for me :
<?xml version="1.0" encoding="UTF-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fillAfter="true"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With