Android BottomSheetDialogFragment does not expand completely
<p>I have the following test bottom sheet implementation. </p>

<p>When I set the peekHeight to a value less than 500, it works. After some value, any increase in peek height will not change how the bottom sheet is expanded. It Just remains there to only drag manually. How do we set the peekHeight programmatically to ensure that the bottom sheet is auto expanded to the peek height.</p>

<p><a href="https://i.stack.imgur.com/C3OgV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/C3OgV.png" alt="enter image description here"></a></p>

<p><strong>bottom_sheet_dialog_main</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/locUXCoordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"&gt;

    &lt;LinearLayout
        android:id="@+id/locUXView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:orientation="vertical"
        app:behavior_hideable="false"
        app:behavior_peekHeight="0dp"
        app:layout_behavior="@string/bottom_sheet_behavior"&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="1 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="2 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="3 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="4 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="5 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="6 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="7 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="8 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="9 Value" /&gt;

        &lt;TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="First Value" /&gt;
    &lt;/LinearLayout&gt;
&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p><strong>Java code</strong></p>

<pre><code>public class MyBottomSheetDialogFragment extends BottomSheetDialogFragment {

    private static BottomSheetBehavior bottomSheetBehavior;
    private static View bottomSheetInternal;
    private static MyBottomSheetDialogFragment INSTANCE;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        getDialog().setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                BottomSheetDialog d = (BottomSheetDialog) dialog;
                CoordinatorLayout coordinatorLayout = (CoordinatorLayout)d.findViewById(R.id.locUXCoordinatorLayout);
                bottomSheetInternal = d.findViewById(R.id.locUXView);
                bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetInternal);
                bottomSheetBehavior.setPeekHeight(bottomSheetInternal.getHeight());
                bottomSheetInternal.requestLayout();
                coordinatorLayout.getLayoutParams().height = bottomSheetInternal.getHeight();
                Toast.makeText(getActivity(), "Height is" + bottomSheetInternal.getHeight() + "  " + coordinatorLayout.getLayoutParams().height, Toast.LENGTH_LONG).show();

            }
        });
        INSTANCE = this;
        return inflater.inflate(R.layout.bottom_sheet_dialog_main, container, false);
    }
}
</code></pre>