Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1.     public void onClick(View cview) throws IOException {
  2.         switch (cview.getId()) {
  3.  
  4.             case R.id.button:
  5.                 View view = findViewById(R.id.menuView);
  6.  
  7.  
  8.                 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1){
  9.                     if (menuVisible) {
  10.                         view.animate().translationX(view.getWidth());
  11.                     } else {
  12.                         view.animate().translationX(0);
  13.                     }
  14.                 } else {
  15.                     ModifiedTranslateAnimation animate;
  16.                     ModifiedTranslateAnimation currentAnimation = (ModifiedTranslateAnimation) view.getAnimation();
  17.  
  18.                     float progress = 1;
  19.                     int time = 1500;
  20.  
  21.                     if (currentAnimation != null) {
  22.                         progress = currentAnimation.getProgress();
  23.                     }
  24.  
  25.                     view.clearAnimation();
  26.                     if (menuVisible) {
  27.                         animate = new ModifiedTranslateAnimation((1-progress) * view.getWidth(), view.getWidth(), 0, 0);
  28.                     } else {
  29.                         animate = new ModifiedTranslateAnimation(progress * view.getWidth(),0,0,0);
  30.                     }
  31.  
  32.                     animate.setDuration((long)(time*progress));
  33.                     animate.setFillAfter(true);
  34.  
  35.                     view.startAnimation(animate);
  36.                 }
  37.  
  38.                 menuVisible = !menuVisible;
  39.               break;
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement