2010-09-12 4 views
2

Je voudrais avoir un bouton dans mon application android déclencher une diapositive en bas d'un formulaire. Je veux avoir une vue en haut de l'écran, une liste en bas de l'écran, et je veux que la vue en bas de la diapositive apparaisse entre les deux quand on clique sur un bouton.Slide vers le bas vers le bas android

Je n'ai aucun problème à afficher la vue, mais je n'arrive pas à l'animer de caché à affiché sur l'écran.

Des idées sur comment cela pourrait fonctionner?

Répondre

8
public void doSlideDown(View view){ 
    RelativeLayout myView = (RelativeLayout)findViewById(R.id.my_view); 
     addListingView.setVisibility(myView.VISIBLE); 

     Animation slideDown = setLayoutAnim_slidedown(); 
     myView.startAnimation(slideDown); 
} 

public void doSlideUp(View view){ 
    RelativeLayout myView = (RelativeLayout)findViewById(R.id.my_view); 

     Animation slideUp = setLayoutAnim_slideup(); 
     myView.startAnimation(slideUp); 

} 

public Animation setLayoutAnim_slidedown() { 

     AnimationSet set = new AnimationSet(true); 

     Animation animation = new TranslateAnimation(
       Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 
       0.0f, Animation.RELATIVE_TO_SELF, -1.0f, 
       Animation.RELATIVE_TO_SELF, 0.0f); 
     animation.setDuration(800); 
     animation.setAnimationListener(new AnimationListener() { 

      @Override 
      public void onAnimationStart(Animation animation) { 
       // TODO Auto-generated method stub 
       // MapContacts.this.mapviewgroup.setVisibility(View.VISIBLE); 

      } 

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

      } 

      @Override 
      public void onAnimationEnd(Animation animation) { 
       // TODO Auto-generated method stub 
       Log.d("LA","sliding down ended"); 

      } 
     }); 
     set.addAnimation(animation); 

     LayoutAnimationController controller = new LayoutAnimationController(
       set, 0.25f); 


     return animation; 
    } 

public Animation setLayoutAnim_slideup() { 

     AnimationSet set = new AnimationSet(true); 

     Animation animation = new TranslateAnimation(
       Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 
       0.0f, Animation.RELATIVE_TO_SELF, 0.0f, 
       Animation.RELATIVE_TO_SELF, -1.0f); 
     animation.setDuration(800); 
     animation.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 
       RelativeLayout bodyView = (RelativeLayout)findViewById(R.id.bodyView); 
       RelativeLayout myView = (RelativeLayout)findViewById(R.id.my_view); 
       addListingView.clearAnimation(); 
       bodyView.removeView(myView); 
      } 
     }); 
     set.addAnimation(animation); 

     LayoutAnimationController controller = new LayoutAnimationController(
       set, 0.25f); 

     return animation; 

}