2011-10-18 2 views
1

J'ai une image que je veux fondre lentement d'opaque à translucide. Je suis la plupart du temps parvins en regardant Animation Resources:Animer une image d'opaque à translucide (et la garder translucide)

mise en page:

<ImageView 
     android:id="@+id/swipeImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerInside" 
     android:src="@drawable/one_finger_swipe" /> 

Activité:

ImageView swipeImage = (ImageView) toReturn.findViewById(R.id.swipeImage); 
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.fadeout); 
    swipeImage.startAnimation(animation); 

res/Anim/fadeout.xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="true" 
    android:interpolator="@android:anim/accelerate_interpolator"> 
    <alpha android:fromAlpha="1.0" 
      android:toAlpha="0.0" 
      android:duration="2000"/> 
</set> 

Comme je l'ai dit Je l'ai surtout fait parce que l'image s'estompe. Cependant, une fois l'animation terminée, elle redevient opaque. Comment puis-je le faire rester translucide?

Répondre

2

Vous devez appeler animation.setFillAfter(true)

android:fillAfter peut également être utilisé en XML.

Questions connexes