title: Set peek height programmatically in BottomSheetDialogFragment
body: <p>I have a <code>BottomSheetDialogFragment</code> that I want to be able to show on any screen. I've spent the day trying to programmatically change the peek height of the sheet, but nothing seems to be changing it.</p>
  
  <p>Here is my layout, <code>bottom_sheet.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;LinearLayout
          android:id="@+id/bottom_sheet"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/white"
          android:orientation="vertical"
          app:behavior_hideable="true"
          app:behavior_peekHeight="96dp"
          app:layout_behavior="@string/bottom_sheet_behavior"&gt;
  
          &lt;androidx.core.widget.NestedScrollView
              android:id="@+id/content"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>You will notice I have an empty <code>NestedScrollView</code>. This is because I have made my content customizable when I show the bottom sheet on different screens, so I load a custom layout into it through code.</p>
  
  <p>Here is my fragment class:</p>
  
  <pre><code>public class BottomSheetFragment extends BottomSheetDialogFragment {
  
      private LinearLayout bottomSheet;
      private NestedScrollView contentView;
  
      public BottomSheetFragment() {
  
      }
  
      @Override
      public void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @Nullable
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          return inflater.inflate(R.layout.bottom_sheet, container, false);
      }
  
      @Override
      public void onViewCreated(@NotNull View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
  
          bottomSheet = view.findViewById(R.id.bottom_sheet);
          contentView = view.findViewById(R.id.content);
      }
  
      // Set the layout of the NestedScrollView by passing a layout ID
      public void setLayout(int layoutId) {
          if (contentView != null) {
              contentView.removeAllViews();
  
              View view = getLayoutInflater().inflate(layoutId, contentView, false);
  
              if (view != null) {
                  contentView.addView(view);
              }
          }
      }
  }
  </code></pre>
  
  <p>Then, where I want to show the bottom sheet, I do:</p>
  
  <pre><code>BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
  bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
  </code></pre>
  
  <p>I want the peek height of the sheet to be 64dp from the top of the screen. How and where would I do this programmatically?</p>
  
  <p>I also found that, even if I change the value of <code>app:behavior_peekHeight="96dp"</code> in the layout to something like 500dp, it still doesn't change anything when I show the sheet.</p>