Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onClick(View cview) throws IOException {
- switch (cview.getId()) {
- case R.id.button:
- View view = findViewById(R.id.menuView);
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1){
- if (menuVisible) {
- view.animate().translationX(view.getWidth());
- } else {
- view.animate().translationX(0);
- }
- } else {
- ModifiedTranslateAnimation animate;
- ModifiedTranslateAnimation currentAnimation = (ModifiedTranslateAnimation) view.getAnimation();
- float progress = 1;
- int time = 1500;
- if (currentAnimation != null) {
- progress = currentAnimation.getProgress();
- }
- view.clearAnimation();
- if (menuVisible) {
- animate = new ModifiedTranslateAnimation((1-progress) * view.getWidth(), view.getWidth(), 0, 0);
- } else {
- animate = new ModifiedTranslateAnimation(progress * view.getWidth(),0,0,0);
- }
- animate.setDuration((long)(time*progress));
- animate.setFillAfter(true);
- view.startAnimation(animate);
- }
- menuVisible = !menuVisible;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement