0

j'ai vu une application, dont le comportement icône dans le délai navigationView sa visibilité (animation Entrée en fondu), mais mon API pour téléphone est 19.Comment retarder NavigationView icônes Visibilité

Ma question est, comment puis-je accéder à ces icônes pour retarder sa visibilité? Est-il possible de l'implémenter sans utiliser de bibliothèque tierce?

Répondre

1

Pour votre vue en Java que vous pouvez faire quelque chose comme ça -

Animation fadeIn = new AlphaAnimation(0, 1); 
fadeIn.setInterpolator(new DecelerateInterpolator()); //add this 
fadeIn.setDuration(1000); 

Animation fadeOut = new AlphaAnimation(1, 0); 
fadeOut.setInterpolator(new AccelerateInterpolator()); //and this 
fadeOut.setStartOffset(1000); 
fadeOut.setDuration(1000); 

AnimationSet animation = new AnimationSet(false); //change to false 
animation.addAnimation(fadeIn); 
animation.addAnimation(fadeOut); 
View.startAnimation(animation); 

Si vous voulez utiliser un seul si vous le souhaitez. Vous pouvez même l'arrêter en appelant l'effacer

View.clearAnimation(); 

ou d'une autre manière

Pour XML, dans votre res/anim dossier créer un fichier, le nom Supposer fadein.xml

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

Et Java

Animation animationFadeIn = AnimationU

tils.loadAnimation(this, R.anim.fadein); 
View.startAnimation(animationFadeOut); 

Utilisation startAnimation() dans une méthode où la navigation devient visible

+0

Je vais tester ce premier, je vous remercie pour votre temps. Qu'est-ce que Tils est en passant et est 'View' se référer à ma navigationView. Je n'ai pas d'expérience en animation, c'est ma première fois. – RoCk

+0

'View' = votre' ImageView' où les icônes sont placées ou il peut même être votre 'TextView' mais certainement je ne le ferai pas sur' NavigationView' sinon cet effet sera sur 'NavigationView' au lieu de l'endroit requis. –