Android Alpha Fade in animation release

I have an ImageView element that I create in my code and place inside my RelativeLayout. I set this image as invisible in order to start using the following code:

arrow.setVisibility(View.INVISIBLE); 

Then I defined the 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 start the animation:

I just call the following to start the animation

 myview.startAnimation(myanimation); 

The problem I see is that my animation causes the ImageView to flicker when fully visible, and then go through the alpha animation from 0 to 1. How can I fix this? I cannot set the initial value of the alpha value to 0, because the alpha animation is based on percentages, not absolute alpha value. (for example: 0 * current value up to 1 * current value)

Any help would be greatly appreciated.

+8
android animation android-animation fadein
source share
1 answer

I think the problem is with this line of code:

 android:fillBefore="true" 

Here, try this code, 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" /> 
+1
source share

All Articles