1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/**
* Utilisée pour ouvrir ou fermer le menu.
* @return true si le menu est désormais ouvert.
*/
public boolean toggle() {
//Animation de transition.
TranslateAnimation animation = null;
// On passe de ouvert à fermé (ou vice versa)
isOpen = !isOpen;
// Si le menu est déjà ouvert
if (isOpen)
{
// Animation de translation du bas vers le haut
animation = new TranslateAnimation(0.0f, 0.0f, -toHide.getHeight(), 0.0f);
animation.setAnimationListener(openListener);
} else
{
// Sinon, animation de translation du haut vers le bas
animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, -toHide.getHeight());
animation.setAnimationListener(closeListener);
}
// On détermine la durée de l'animation
animation.setDuration(SPEED);
// On ajoute un effet d'accélération
animation.setInterpolator(new AccelerateInterpolator());
// Enfin, on lance l'animation
startAnimation(animation);
return isOpen;
} |
Partager