2017-06-26 6 views
1

Je crée une animation dans laquelle je veux effacer mon imageview mais l'animation devrait commencer la décoloration de bas en haut contrairement à la décoloration animation dans laquelle tout imageview disparaît à la fois.Android Fade In/Out animation de bas en haut

public void animateFadeIn() { 
    Animation in = AnimationUtils.loadAnimation(this, 
      android.R.anim.fade_in); 
    motherboard.startAnimation(in); 
    motherboard.setVisibility(View.VISIBLE); 
    in.setDuration(1500); 
    in.setAnimationListener(new AnimationListener() { 

     @Override 
     public void onAnimationStart(Animation animation) { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onAnimationRepeat(Animation animation) { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onAnimationEnd(Animation animation) { 
      // TODO Auto-generated method stub 
      animateFadeOut(); 
     } 
    }); 
} 

Comment y parvenir.

<?xml version="1.0" encoding="UTF-8"?> 

<scale 
    android:fromYScale="-450" 
    android:toYScale="450" /> 

<alpha 
    android:duration="1500" 
    android:fromAlpha="0.0" 
    android:interpolator="@android:anim/accelerate_interpolator" 
    android:repeatCount="infinite" 
    android:toAlpha="1.0" /> 

+0

suivre ce lien peut vous aider à http://www.androidhive.info/2013/06/android-working-with-xml-animations/ –

+0

coller votre animation. fichiers xml –

+0

@NileshRathod Je suis simplement en utilisant xml d'animation Android par défaut. ** android.R.anim.fade_in ** et ** android.R.anim.fade_out ** –

Répondre

0

créer un slide_up.xml dans votre

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
<translate 
    android:duration="5000" 
    android:fillAfter="true" 
    android:fromYDelta="75%p" 
    android:repeatCount="0" 
    android:toYDelta="0%p" /> 

votre fade_in.xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillAfter="true" > 

    <alpha 
    android:duration="1000" 
    android:fromAlpha="0.0" 
    android:interpolator="@android:anim/accelerate_interpolator" 
    android:toAlpha="1.0" /> 

</set> 

que la charge animation

ImageView imageview; 
Animation animFadein, animslideup; 

animFadein = AnimationUtils.loadAnimation(getApplicationContext(), 
      R.anim.fade_in); 
    animslideup = AnimationUtils.loadAnimation(getApplicationContext(), 
      R.anim.slide_up); 

final AnimationSet s = new AnimationSet(true); 
    s.setInterpolator(new AccelerateInterpolator()); 

    s.addAnimation(animslideup); 
    s.addAnimation(animFadein); 
    imageview.startAnimation(s); 
+0

l'image est bien animée grâce à votre code ci-dessus. Mais une chose que je veux vraiment réaliser est quand l'animation commence, l'image commence à disparaître du fond et s'estompe ensuite jusqu'au sommet. Pouvez-vous s'il vous plaît aidez-moi s'il vous plaît avec ce –

+0

les images ne disparaît pas avec effet de fondu. Il disparaît simplement avec une glissière du bas vers le haut. Je veux obtenir une animation similaire à [Master Refroidissement] (https://play.google.com/store/apps/details?id=com.easyx.coolermaster) Référence de l'image -2 –

+0

pourrait vous aider s'il vous plaît me avec ce –