MrEngineer13 / SnackBar

toast-like alert pattern for Android inspired by the Google Material Design Spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onShow onHide listener

alorma opened this issue · comments

Hi.

I need to modify the UI when the snackbar is shown.

Default UI
UI with Snackbar

But now the SnackBar is shown above the Button
Button behind

How can I achieve this with this library?

you can implement withVisibilityChangeListener(); in your SnackBar. here is mine using floating action button:

new SnackBar.Builder(ActivityHome.this)
                    .withMessage(getString(R.string.distance_alert))
                    .withVisibilityChangeListener(new SnackBar.OnVisibilityChangeListener() {
                        @Override
                        public void onShow(int i) {
                            ViewPropertyAnimator.animate(mFabLocation).cancel();
                      ViewPropertyAnimator.animate(mFabLocation).translationY(-72).setDuration(200).start();
                        }
                        @Override
                        public void onHide(int i) {
                            ViewPropertyAnimator.animate(mFabLocation).cancel();
                         ViewPropertyAnimator.animate(mFabLocation).translationY(0).setDuration(200).start();
                        }
                    })
                    .show();