Skip to content

Instantly share code, notes, and snippets.

@vaibhav-jani
Created December 19, 2015 04:58
Show Gist options
  • Select an option

  • Save vaibhav-jani/26633833960748289f86 to your computer and use it in GitHub Desktop.

Select an option

Save vaibhav-jani/26633833960748289f86 to your computer and use it in GitHub Desktop.
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