material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.32k stars 3.06k forks source link

[Snackbar] Override Default Snackbar animation #2030

Open jdelga opened 3 years ago

jdelga commented 3 years ago

Is your feature request related to a problem? Please describe. Limited snackbar animations - Slide or Fade

Describe the solution you'd like I would like to use a custom animation through theme, xml or setAnimation

Describe alternatives you've considered Currently I need to create a whole Snackbar class to override it or use it through custom views and visibilty handling of the default animation

Current animateView is fixed to one of these two options. I would like to add my custom animation somehow:

  void animateViewIn() {
    // Post to make sure animation doesn't start until after all inset handling has completed
    view.post(
        new Runnable() {
          @Override
          public void run() {
            if (view == null) {
              return;
            }
            // Make view VISIBLE now that we are about to start the enter animation
            view.setVisibility(View.VISIBLE);
            if (view.getAnimationMode() == ANIMATION_MODE_FADE) {
              startFadeInAnimation();
            } else {
              startSlideInAnimation();
            }
          }
        });
  }
TelephoneTan commented 3 years ago

wow! amazing!