This GIF pretty much shows what I'm talking about:

I have a rather complicated scheme DrawerLayout -> CoordinatorLayout -> ViewPager -> Fragment -> RecyclerView, which happens in my application.
When the user long clicks on one of the elements in the RecyclerView, he sends a broadcast to ParentActivity, which then signals the appearance of the BottomSheet.
It usually works fine, but from time to time BottomSheet does not appear. I have a FrameLayout that acts as an overlay between ParentActivity and ViewPager. When you click Overlay, it reports a BottomSheet failure. You can see in the GIF above that in situations where the BottomSheet does not appear, it still animates when it crashes.
This behavior occurs quite often on the Nexus 5 Genymotion emulator (API 21). On real devices, this almost never happens, but sometimes it happens.
I noticed that if I make a long click and hold it until BottomSheet appears, it will always appear. This is when I release right after a long click is registered that the BottomSheet may not be displayed.
I'm sure this is a situation where the RecyclerView intervenes somehow, but I cannot understand why and how. Any debugging tips would be appreciated.
For reference, a layout is considered here:
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/green"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/budget_display_mode_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green"
android:elevation="4dp"
android:visibility="gone"
app:tabGravity="fill"
app:tabIndicatorColor="@color/green"
app:tabMode="fixed" />
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray"
android:orientation="vertical" />
</FrameLayout>
<FrameLayout
android:id="@+id/primary_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:background="@null"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progress"
style="@style/ProgressBar"/>
</FrameLayout>
<LinearLayout
android:id="@+id/full_screen_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@color/blackLight"
android:orientation="vertical"/>
<LinearLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:background="@color/gray"
android:orientation="vertical"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<TextView
android:id="@+id/bottom_edit"
style="@style/BottomSheetButton"
android:text="@string/option 1"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/nav_list"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="@color/kEDColorGrayLightest" />
</android.support.v4.widget.DrawerLayout>
primaryViewand contentset to View.GONEwhen ViewPager is enabled.
This is the receiver that launches the bottom sheet:
private final BroadcastReceiver modifyBudgetItemBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
fullScreenOverlay.setVisibility(View.VISIBLE);
}
};
: . BottomSheetBehavior, , BottomSheet Expand, bottomSheet.requestLayout() , , , . , - , "", , . requestLayout .