Search code examples
androidcrouton

Crouton not showing outAnimation


I show a Crouton like this:

    Builder b = new Builder();
    b.setBackgroundColor(R.color.mygreen);
    b.setTextAppearance(R.style.LargeTextWhite);
    Configuration.Builder configBuilder = new Configuration.Builder();
    configBuilder.setInAnimation(R.anim.slide_up).setOutAnimation(
            R.anim.shake);
    b.setConfiguration(configBuilder.build());
    Crouton.makeText(getActivity(),
            "" + e.getResult().getTotalCount() + " Treffer", b.build(),
            root).show();

where root is a ViewGroup;

The inAnimation is shown, the outAnimation is not, the Crouton just diappears. Anyone else has experienced this too or has an idea why it's not working?


Solution

  • I met the problem too,I check the demo's source and found that, your "root" should be :

    <LinearLayout
                android:id="@+id/croutonContainer"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" />
    
    
    private void showCustomViewCrouton() {
            View view = getLayoutInflater(null).inflate(R.layout.layout_crouton_custom_view, null);
            final Crouton crouton;
            final Configuration croutonConfig =  new Configuration.Builder().setDuration(Configuration.DURATION_SHORT).setInAnimation(android.R.anim.fade_in).setOutAnimation(android.R.anim.fade_out).build();
            crouton = Crouton.make(getActivity(), view, R.id.croutonContainer, croutonConfig);
            crouton.show();
          }
    

    and finally fixed my problem.Hope it work for you:)