Crouton + SlidingMenu overlap
Asked Answered
T

1

8

I'm using both SlidingMenu and Crouton, but I've found that the sliding menu overlaps the crouton notification

crouton and slidingmenu overlap

I would report an issue in github, but I don't know where the bug belongs.

Cyril Mottier mentions in his Prixing article about in-layout notifications the existence of 3 Contexts, the left menu having a Context on its own. That way, the Notification slides with the rest of the content.

enter image description here

Because both SlidingMenu and Crouton use the Activity Context, maybe this simply isn't fixable. We can easily call

Crouton.cancelAllCroutons();

before displaying the SlidingMenu, but I like Prixing's slide-out feature.

Hopefully the library authors can claim the bug or shed some light on it.

Thanks!

EDIT:

I'm using the SlidingMenu by creating the object and attaching it to the activity

private void configureSideMenu() {
   mSlidingMenu = new SlidingMenu(this);
   mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
   mSlidingMenu.setFadeDegree(0.35f);
   mSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
   mSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
   mSlidingMenu.setMenu(R.layout.menu_frame);
   getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new MySideMenuFragment()).commit();
 }

And the Crouton, I guess there's only one way to use it

  Crouton.showText(this, R.string.error_not_logged_in, Style.ALERT);

Where this is the same Activity for both cases

Tanagra answered 15/3, 2013 at 13:13 Comment(2)
How are you building the SlidingMenu and displaying the Crouton? I am extending SlidingActivity and I do not have this issue.Cosmography
@Cosmography thanks, see updated question. Maybe if I extended from SlidingActivity that would fix the issue... I'll try it, and if it fixes it I'll report a bug in the SlidingMenu project, as I don't remember to read there were differences in using the library one way or another (perhaps I'm wrong and it's specified)Tanagra
L
6

You can easily attach a Crouton to a specific ViewGroup.

All you need to do is call Crouton.makeText(Activity, CharSequence, Style, ViewGroup), Crouton.make(...) or Crouton.show(...).

The created Crouton then is attached to the ViewGroup and will slide out with it's parent when the SlidingMenu opens.

So, when you're creating the Crouton from a Fragment

Crouton.showText(this, R.string.error_not_logged_in, Style.ALERT, (ViewGroup) getView());

Else you can add it to any ViewGroup (even by resource id), although I recommend to have a FrameLayout to attach the Crouton to.

Leavis answered 22/3, 2013 at 14:10 Comment(1)
Thanks! I've successfully implemented your solution, but to extend it to all my screens I'd have to go over every .xml and add an extra View at the top, which sounds very bad and hard to mantain :-/ Simply attaching it to the content [(ViewGroup) mSlidingMenu.getContent()] respects the layout gravity properties, thus the crouton may end up placed in the middle of the screen. Anyway, thanks a lot for the library and for your time.Tanagra

© 2022 - 2024 — McMap. All rights reserved.