Created
December 19, 2015 04:58
-
-
Save vaibhav-jani/26633833960748289f86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { | |
| @Override | |
| public void onDrawerSlide(View drawerView, float slideOffset) { | |
| float moveFactor = (drawerView.getWidth() * slideOffset); | |
| float total = drawerView.getMeasuredWidth(); | |
| total = (total == 0) ? 1 : total; | |
| float percent = moveFactor / total; | |
| //float x = ((int) moveFactor) == 0 ? 1 : 900 / moveFactor; | |
| float y = 1 - percent; | |
| final float MIN_SCALE = 0.85f; | |
| y = (y < MIN_SCALE) ? MIN_SCALE : y; | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | |
| rlContentAndToolBar.setTranslationX(moveFactor); | |
| //rlContentAndToolBar.setScaleX(x); | |
| rlContentAndToolBar.setScaleY(y); | |
| } else { | |
| TranslateAnimation anim = new TranslateAnimation(lastTranslate, moveFactor, 0.0f, 0.0f); | |
| anim.setDuration(0); | |
| anim.setFillAfter(true); | |
| rlContentAndToolBar.startAnimation(anim); | |
| ScaleAnimation scaleAnimation = new ScaleAnimation(0, 0, 0, y); | |
| scaleAnimation.setDuration(0); | |
| scaleAnimation.setFillAfter(true); | |
| rlContentAndToolBar.startAnimation(scaleAnimation); | |
| lastTranslate = moveFactor; | |
| } | |
| } | |
| @Override | |
| public void onDrawerOpened(View drawerView) { | |
| } | |
| @Override | |
| public void onDrawerClosed(View drawerView) { | |
| } | |
| @Override | |
| public void onDrawerStateChanged(int newState) { | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment