title: Show bottom sheet when activity starts
body: <p>I am trying to keep my bottom sheet visible at a specific height of 250dp when activity is started and show it on full screen when a button is clicked. Unfortunately, my bottom sheet is not visible when activity starts.
  I am using a persistent bottom sheet instead of a fragment because i would like to still use other parts of the window. Kindly how may i go about this.</p>
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main_layout);
    
      rootFrame = (RelativeLayout) findViewById(R.id.rootFrame);
      bottomlay = findViewById(R.id.bottom_sheet);
      layoutParams = bottomlay.getLayoutParams();
      bottomSheetBehavior = BottomSheetBehavior.from(bottomlay);
      bottomSheetBehavior.setPeekHeight(250);
      bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
  
       edtWhere = (ImageButton)findViewById(R.id.edtWhere);
  
         btnClose = (ImageButton)findViewById(R.id.btnClose);
          btnClose.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
             
          }
          });
         
      edtWhere.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              
                      int windowHeight = getWindowHeight();
                      if (layoutParams != null) {
                          layoutParams.height = windowHeight;
                      }
                      bottomlay.setLayoutParams(layoutParams);
                      bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                
          
           });
    @Override
     protected void onStart() {
      super.onStart();
      
      bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
  
     }
  </code></pre>
  <p>bottomsheet layout</p>
  <pre><code>   &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
     &lt;androidx.core.widget.NestedScrollView 
     xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_gravity=&quot;bottom&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;250dp&quot;
      app:behavior_hideable=&quot;false&quot;
      app:behavior_peekHeight=&quot;250dp&quot;
      android:id=&quot;@+id/bottom_sheet&quot;
      android:background=&quot;@color/white&quot;
      app:layout_behavior=&quot;com.google.android.material.bottomsheet.BottomSheetBehavior&quot;&gt;
  
       &lt;ImageButton
        android:id=&quot;@+id/btnClose&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:src=&quot;@drawable/com_facebook_close&quot;
        android:background=&quot;@color/transparent&quot;
        android:layout_margin=&quot;20dp&quot;/&gt;
  
      &lt;/androidx.core.widget.NestedScrollView&gt;
  </code></pre>