Added fragment sometimes overlays the snackbar
MFlisar opened this issue · 5 comments
I see following problem:
When I first add a fragment and this fragment shows a snackbar, everything works. If I remove the fragment and readd a new one, the snackbar shown from the fragment is behind this new fragment... I see it, because when I press back and remove the new fragment and reattach the previous one again, I see the snackbar over the previous fragment...
What works for me, as a work around, is following:
mCurrentSnackbar.show(parent);
mCurrentSnackbar.postDelayed(new Runnable()
{
@Override
public void run()
{
mCurrentSnackbar.bringToFront();
}
}, 500);
Thanks for reporting this. Calling bringToFront() inside the show() method should solve this, I'll test it when I get a chance
Actually, I tried this already... It may be some timing problem... In my case, your solution did not work... Only my solution with the delay worked... Of course, this has some drawbacks... As animation won't work perfectly as it would have to be timed according to the delay...
:-/
Hi. I was also facing this issue, but I have fixed it by adding SnackbarManager.show(Snackbar, ViewGroup)
method.
Forked code: https://github.com/h6ah4i/snackbar/tree/feature/attach_to_non_activity_root_view
ViewGroup snackbarContainer = (ViewGroup) findViewById(R.id.snackbar_conatiner);
SnackbarManager.show(new Snackbar(), snackbarContainer);
<RelativeView>
<FrameLayout android:id="fragment_container" />
<FrameLayout android:id="snackbar_container" android:layout_alignParentBottom="true" />
</RelativeView>