android animation slidedown slideup


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public void setLayoutAnim_slidedown(ViewGroup panel, Context ctx) {
  2.  
  3. AnimationSet set = new AnimationSet(true);
  4.  
  5. Animation animation = new TranslateAnimation(
  6. Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
  7. 0.0f, Animation.RELATIVE_TO_SELF, -1.0f,
  8. Animation.RELATIVE_TO_SELF, 0.0f);
  9. animation.setDuration(800);
  10. animation.setAnimationListener(new AnimationListener() {
  11.  
  12. @Override
  13. public void onAnimationStart(Animation animation) {
  14. // TODO Auto-generated method stub
  15. // MapContacts.this.mapviewgroup.setVisibility(View.VISIBLE);
  16.  
  17. }
  18.  
  19. @Override
  20. public void onAnimationRepeat(Animation animation) {
  21. // TODO Auto-generated method stub
  22.  
  23. }
  24.  
  25. @Override
  26. public void onAnimationEnd(Animation animation) {
  27.  
  28. // TODO Auto-generated method stub
  29.  
  30. }
  31. });
  32. set.addAnimation(animation);
  33.  
  34. LayoutAnimationController controller = new LayoutAnimationController(
  35. set, 0.25f);
  36. panel.setLayoutAnimation(controller);
  37.  
  38. }
  39.  
  40. public void setLayoutAnim_slideup(ViewGroup panel, Context ctx) {
  41.  
  42. AnimationSet set = new AnimationSet(true);
  43.  
  44. /*
  45. * Animation animation = new AlphaAnimation(1.0f, 0.0f);
  46. * animation.setDuration(200); set.addAnimation(animation);
  47. */
  48.  
  49. Animation animation = new TranslateAnimation(
  50. Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
  51. 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
  52. Animation.RELATIVE_TO_SELF, -1.0f);
  53. animation.setDuration(800);
  54. animation.setAnimationListener(new AnimationListener() {
  55.  
  56. @Override
  57. public void onAnimationStart(Animation animation) {
  58. // TODO Auto-generated method stub
  59.  
  60. }
  61.  
  62. @Override
  63. public void onAnimationRepeat(Animation animation) {
  64. // TODO Auto-generated method stub
  65.  
  66. }
  67.  
  68. @Override
  69. public void onAnimationEnd(Animation animation) {
  70. // MapContacts.this.mapviewgroup.setVisibility(View.INVISIBLE);
  71. // TODO Auto-generated method stub
  72.  
  73. }
  74. });
  75. set.addAnimation(animation);
  76.  
  77. LayoutAnimationController controller = new LayoutAnimationController(
  78. set, 0.25f);
  79. panel.setLayoutAnimation(controller);
  80.  
  81. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.