9

The Crouton should ideally display underneath the toolbar, for context-sensitive updates that don't block content actions.

I apologise if this is a double-post, because I think I initially submitted it to the wrong community.

enter image description here

5
  • Rather than cross posting, you should have just flagged your MSO question for migration. May 6, 2015 at 17:33
  • Ah cool. I didn't know that. Will I delete this one and flag the other so? May 6, 2015 at 17:40
  • Just leave it be for now. If/when the other gets migrated, they can be merged or closed as dups. May 6, 2015 at 17:48
  • 2
    Bah! Switching over to Toolbar has caused me so much grief. Thanks for reporting this, will fix it up for the next update :) May 7, 2015 at 7:26
  • No problem! Glad to help :) May 7, 2015 at 7:28

2 Answers 2

1

This will be fixed in 1.0.85.

As Paul described, the issue is that the crouton wasn't attached to anything in the activity. I've fixed this in three places:

  1. Any activity that uses BaseActivity. (feed, question list, question, ...) This already had a content FrameLayout around the body fragment.
  2. Asking/Editing a question. I wrapped its three fragments in a FrameLayout and discovered some assumptions we had around the truly shocking behavior of the support FragmentTransaction and the behavior of multiple fragments.
  3. Adding/Editing an answer. Same as 2.

There may be other areas that don't use this base layout (like registration) which will still get obscured in the toolbar. This is the bulk of the issue though.

0
2

The Crouton library displays over the actionbar/toolbar when called from an Activity's context, without the viewgroup parameter.

Creating a small FrameLayout above your main content and attaching the crouton to this will fix the issue.

  <FrameLayout
    android:id="@+id/crouton"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize">

Note: choosing wrap-content for your layout-height will cause the crouton to be consumed by the layout before it is properly cancelled, causing double notifications or jerky behaviour.

Crouton.makeText(
      MainActivity.this,
      croutonText,
      croutonStyle,
      R.id.crouton
 ).show();

Alternatively, you can directly attach it to the content view, if you wish to do it programmatically:

// Find content view and cast to ViewGroup, to attach crouton
View homeBtn = findViewById(android.R.id.content);
Crouton.makeText(
      MainActivity.this,
      croutonText,
      croutonStyle,
      (ViewGroup) homeBtn)
 ).show();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .