Collapsing Toolbar Layout is not expanded at first time and pin doesn't work

I found my mistake. I used my code in normal Activity and it works fine. It doesn't work correctly in the BottomSheet.

The promblem is about the BottomSheet but I don't know how to fix that. Anyway, This problem is solved by using a Simple Activity.


add android:fitsSystemWindows="true" in CoordinatorLayout and CollapsingToolbarLayout. app:elevation="5dp" app:expanded="true" is not necessary . remove LinearLayout and place a FrameLayout

<android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:title="ASDASD">

        <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="252dp"/>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_gravity="bottom"
            android:layout_marginTop="230dp"
            android:layout_height="wrap_content">

        <me.relex.circleindicator.CircleIndicator
                android:id="@+id/indicator"
                android:layout_width="match_parent"
                app:ci_drawable="@drawable/circleindicator_round"
                android:layout_height="48dp"
                android:layout_gravity="bottom"
                android:gravity="bottom"
                android:visibility="visible"/>

        </FrameLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin">

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.CollapsingToolbarLayout>

and remove android:fillViewport="false" in NestedScrollView